Skip to content

Open-source status page, incident response and uptime monitoring

fix(status-page): make badge status API URL configurable (#2622)

Waltrickaa2a85995f49
diff --git a/coolify-deployment.yaml b/coolify-deployment.yaml
index f430ab19d..8af689682 100644
--- a/coolify-deployment.yaml
+++ b/coolify-deployment.yaml
@@ -329,6 +329,7 @@ services:
- PORT=${STATUS_PAGE_PORT:-3000}
- HOSTNAME=${STATUS_PAGE_HOSTNAME:-0.0.0.0}
- AUTH_TRUST_HOST=${STATUS_PAGE_AUTH_TRUST_HOST:-true}
+ - OPENSTATUS_API_URL=${OPENSTATUS_API_URL:-http://server:3000}
depends_on:
workflows:
condition: service_healthy
diff --git a/docker-compose.github-packages.yaml b/docker-compose.github-packages.yaml
index 09de8d102..334361fb2 100644
--- a/docker-compose.github-packages.yaml
+++ b/docker-compose.github-packages.yaml
@@ -285,6 +285,7 @@ services:
- PORT=3000
- HOSTNAME=0.0.0.0
- AUTH_TRUST_HOST=true
+ - OPENSTATUS_API_URL=${OPENSTATUS_API_URL:-http://server:3000}
depends_on:
db-migrate:
condition: service_completed_successfully
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 309ab6b88..5f5f652fd 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -267,6 +267,7 @@ services:
- PORT=3000
- HOSTNAME=0.0.0.0
- AUTH_TRUST_HOST=true
+ - OPENSTATUS_API_URL=${OPENSTATUS_API_URL:-http://server:3000}
depends_on:
db-migrate:
condition: service_completed_successfully
diff --git a/packages/react/src/widget.tsx b/packages/react/src/widget.tsx
index 96ec64ee8..f64578581 100644
--- a/packages/react/src/widget.tsx
+++ b/packages/react/src/widget.tsx
@@ -11,16 +11,26 @@ export type Status =
export type StatusResponse = { status: Status };
-export async function getStatus(slug: string): Promise<StatusResponse> {
- const res = await fetch(`https://api.openstatus.dev/public/status/${slug}`, {
- cache: "no-cache",
- });
-
- if (res.ok) {
- const data = (await res.json()) as StatusResponse;
- return data;
- }
+export async function getStatus(
+ slug: string,
+ baseUrl = process.env.OPENSTATUS_API_URL ?? "https://api.openstatus.dev",
+): Promise<StatusResponse> {
+ // read at runtime on the server: no NEXT_PUBLIC_ prefix, so deployments
+ // shipping prebuilt images can still point badges at their own API
+ const base = baseUrl.replace(/\/+$/, "") || "https://api.openstatus.dev";
+ try {
+ const res = await fetch(`${base}/public/status/${slug}`, {
+ cache: "no-cache",
+ });
+ if (res.ok) {
+ const data = (await res.json()) as StatusResponse;
+ return data;
+ }
+ } catch {
+ // network-level failures (unreachable host, DNS, …) degrade to "unknown"
+ // instead of bubbling a 500 out of the badge routes
+ }
return { status: "unknown" };
}