Skip to content

Beautiful Open-Source Form Builder

#365 Use relative urls in the browser to avoid needing to hardcode the domain name (#375)

Don Benjamin75c2107b6c76
diff --git a/client/.env.docker b/client/.env.docker
index 3b55165b9..ced6ff238 100644
--- a/client/.env.docker
+++ b/client/.env.docker
@@ -1,6 +1,7 @@
NUXT_LOG_LEVEL=
-NUXT_PUBLIC_APP_URL=http://localhost/
-NUXT_PUBLIC_API_BASE=http://localhost/api
+NUXT_PUBLIC_APP_URL=/
+NUXT_PUBLIC_API_BASE=/api
+NUXT_PRIVATE_API_BASE=http://localhost/api
NUXT_PUBLIC_AI_FEATURES_ENABLED=false
NUXT_PUBLIC_AMPLITUDE_CODE=
NUXT_PUBLIC_CRISP_WEBSITE_ID=
diff --git a/client/composables/useOpnApi.js b/client/composables/useOpnApi.js
index 7f1ff8ff4..c278a2894 100644
--- a/client/composables/useOpnApi.js
+++ b/client/composables/useOpnApi.js
@@ -47,7 +47,7 @@ export function getOpnRequestsOptions(request, opts) {
addPasswordToFormRequest(request, opts)
addCustomDomainHeader(request, opts)
- if (!opts.baseURL) opts.baseURL = config.public.apiBase
+ if (!opts.baseURL) opts.baseURL = config.privateApiBase || config.public.apiBase
return {
async onResponseError({response}) {
diff --git a/client/runtimeConfig.js b/client/runtimeConfig.js
index 80cbc25fc..eb1414a6d 100644
--- a/client/runtimeConfig.js
+++ b/client/runtimeConfig.js
@@ -25,4 +25,5 @@ export default {
* Used to authenticate that the requests are coming from the server - not from a client.
*/
apiSecret: process.env.NUXT_API_SECRET || '',
+ privateApiBase: process.env.NUXT_PRIVATE_API_BASE || null,
}
diff --git a/docker/nuxt-wrapper.sh b/docker/nuxt-wrapper.sh
index 3b7f2084c..8eb246c99 100644
--- a/docker/nuxt-wrapper.sh
+++ b/docker/nuxt-wrapper.sh
@@ -10,6 +10,8 @@ nvm use 20
cd /app/nuxt/server/
+export NUXT_PRIVATE_API_BASE=http://localhost/api
+
echo + . /app/client/.env
[ -f /app/client/.env ] && . /app/client/.env || echo "Environment file missing!"