diff --git a/.env.example b/.env.example index f9327652a..ec0143878 100644 --- a/.env.example +++ b/.env.example @@ -60,6 +60,11 @@ POSTGREST_URL_EXTERNAL=http://localhost/api/v1 # .env.local: http://localhost/auth, .env: http://auth:7000 RSD_AUTH_URL=http://auth:7000 +# RSD Reverse Proxy URL +# consumed by services: frontend +# .env.local: http://localhost, .env: http://nginx +RSD_REVERSE_PROXY_URL=http://nginx + # consumed by services: authentication # If set to "dev", the first user to log in will become admin. # Any other value doesn't activate this feature (and doesn't do anything). diff --git a/docker-compose.yml b/docker-compose.yml index 5d6d5dd17..1965f0ff1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -118,6 +118,7 @@ services: - RSD_AUTH_URL - RSD_AUTH_PROVIDERS - RSD_AUTH_COUPLE_PROVIDERS + - RSD_REVERSE_PROXY_URL - MATOMO_URL - MATOMO_ID - SURFCONEXT_CLIENT_ID @@ -149,7 +150,8 @@ services: - database - backend - auth - # volumes: + volumes: + - ./frontend/public:/app/public # - ./deployment/hmz/styles:/app/public/styles # - ./deployment/hmz/data:/app/public/data # - ./deployment/hmz/images:/app/public/images diff --git a/frontend/config/getPlugins.ts b/frontend/config/getPlugins.ts index 8789d1cc7..1e5a2fb65 100644 --- a/frontend/config/getPlugins.ts +++ b/frontend/config/getPlugins.ts @@ -9,8 +9,20 @@ import logger from '~/utils/logger' import {createJsonHeaders} from '~/utils/fetchHelpers' import {PluginConfig} from '~/config/RsdPluginContext' -async function getPlugin({pluginName,token}:{pluginName: string, token?: string}){ - const url = `http://localhost/plugin/${pluginName}/api/config` + +function getPluginBaseUrl(pluginName: string) { + if (/^(https?:\/\/)/.test(pluginName)) { + return pluginName + } else if (process.env.NODE_ENV === 'development') { + return `http://localhost/plugin/${pluginName}` + } else { + const baseUrl = process.env.RSD_REVERSE_PROXY_URL ?? 'http://nginx' + return `${baseUrl}/plugin/${pluginName}` + } +} + +async function getPlugin({pluginName, token}:{pluginName: string, token?: string}){ + const url = getPluginBaseUrl(pluginName) + '/api/v1/config' try { const response = await fetch(url, { headers: {