Merge branch 'copilot/vcard-api-integraciones-anlisis'

This commit is contained in:
Lizandro Guarnizo
2026-05-25 21:40:09 -05:00
+7 -2
View File
@@ -54,12 +54,17 @@ func coolifyProxy(c *fiber.Ctx, method, endpoint string) error {
}
body, status, err := coolifyDo(method, ep, bodyReader, ct, cfg)
if err != nil {
return c.Status(fiber.StatusBadGateway).JSON(fiber.Map{"error": err.Error()})
// No devolver 502: Cloudflare lo intercepta y oculta el error al frontend
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "No se pudo conectar a Coolify: " + err.Error()})
}
var result json.RawMessage
if err := json.Unmarshal(body, &result); err != nil {
result = json.RawMessage(fmt.Sprintf(`{"raw":%q}`, string(body)))
}
// Si Coolify devuelve 5xx, bajar a 400 para que Cloudflare no lo intercepte
if status >= 500 {
status = fiber.StatusBadRequest
}
c.Status(status)
return c.JSON(result)
}
@@ -122,7 +127,7 @@ func CoolifyTestConnection(c *fiber.Ctx) error {
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Get(base + "/api/health")
if err != nil {
return c.Status(fiber.StatusBadGateway).JSON(fiber.Map{"error": err.Error()})
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "No se pudo conectar a Coolify: " + err.Error()})
}
defer resp.Body.Close()
body, _ := io.ReadAll(io.LimitReader(resp.Body, 64*1024))