Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: resolve ECONNREFUSED for server-side API calls in self-hosted Docker setup

Blue Mousef45940644b44
diff --git a/web/Dockerfile b/web/Dockerfile
index 4f201c0ff..8b9ef7ac4 100644
--- a/web/Dockerfile
+++ b/web/Dockerfile
@@ -37,7 +37,8 @@ RUN npm run build
FROM base
ENV NODE_ENV=production \
- __SELFHOSTED=true
+ __SELFHOSTED=true \
+ API_ORIGIN=http://swetrix-api:5005
RUN mkdir /app
WORKDIR /app
diff --git a/web/app/lib/constants/index.ts b/web/app/lib/constants/index.ts
index 77fc08be1..233e4c746 100644
--- a/web/app/lib/constants/index.ts
+++ b/web/app/lib/constants/index.ts
@@ -381,7 +381,7 @@ const PRODUCTION_API_URL = isBrowser
: process.env.API_URL
const SELFHOSTED_API_URL = isBrowser
? `${window.REMIX_ENV?.BASE_URL}/backend`
- : `${process.env.BASE_URL}/backend`
+ : process.env.API_ORIGIN || `${process.env.BASE_URL}/backend`
export const COOKIE_DOMAIN =
(isBrowser ? window.REMIX_ENV?.COOKIE_DOMAIN : process.env.COOKIE_DOMAIN) ||