From 9b3e02ea6751943db12eb0135f74d8c2ff759ee8 Mon Sep 17 00:00:00 2001 From: StanR Date: Thu, 19 Oct 2023 00:19:21 +0300 Subject: [PATCH] Use envvar host --- docker-compose.yml | 2 ++ frontend/src/lib/api.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 95c16e8..39f731e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -35,6 +35,8 @@ services: build: ./frontend/. ports: - "127.0.0.1:3500:3000" + environment: + - HOSTNAME volumes: - ./logs/frontend:/app/logs networks: diff --git a/frontend/src/lib/api.js b/frontend/src/lib/api.js index c04f1f3..f738e3d 100644 --- a/frontend/src/lib/api.js +++ b/frontend/src/lib/api.js @@ -1,5 +1,6 @@ const isDev = process.env.NODE_ENV === "development"; -const apiBase = isDev ? 'http://localhost/api' : 'https://mutualify.stanr.info/api'; +const host = process.env.HOSTNAME; +const apiBase = isDev ? 'http://localhost/api' : 'https://'+host+'/api'; export default async function api (endpoint, options) { const response = await fetch(`${apiBase}${endpoint}`, {