diff --git a/README.md b/README.md index 87b4f44e5..91ac65dab 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ Each component (frontend, admin, backend and database) has its own `.env` file. Each component has a `.env.dist` file. This file contains all environment variables used by the component and can be used as pattern. If you want to use a local `.env`, copy the `.env.dist` and adjust the variables accordingly. -Each component has a `.env.template` file. These files are very important on deploy. +Each component has a `.env.template` file. These files are very important on deploy. They use COMMUNITY_HOST instead of different urls for different modules because in deploy using nginx is expected for routing incoming request to the correct module There is one `.env.dist` in the `deployment/bare_metal/` folder. This `.env.dist` contains all variables used by the components, e.g. unites all `.env.dist` from the components. On deploy, we copy this `.env.dist` to `.env` and set all variables in this new file. The deploy script loads this variables and provides them by the `.env.templates` of each component, creating an `.env` for each component (see in `deployment/bare_metal/start.sh` the `envsubst`). diff --git a/admin/.env.dist b/admin/.env.dist index 66c84dda8..d92f3d9bc 100644 --- a/admin/.env.dist +++ b/admin/.env.dist @@ -1,4 +1,6 @@ -GRAPHQL_URI=http://localhost:4000/graphql -WALLET_AUTH_URL=http://localhost/authenticate?token={token} -WALLET_URL=http://localhost/login +GRAPHQL_URL=http://localhost:4000 +GRAPHQL_PATH=/graphql +WALLET_URL=http://localhost +WALLET_AUTH_PATH=/authenticate?token={token} +WALLET_LOGIN_PATH=/login DEBUG_DISABLE_AUTH=false \ No newline at end of file diff --git a/admin/.env.template b/admin/.env.template index 488c9aba4..636b15593 100644 --- a/admin/.env.template +++ b/admin/.env.template @@ -1,6 +1,7 @@ CONFIG_VERSION=$ADMIN_CONFIG_VERSION -GRAPHQL_URI=$GRAPHQL_URI -WALLET_AUTH_URL=$WALLET_AUTH_URL -WALLET_URL=$WALLET_URL -DEBUG_DISABLE_AUTH=false \ No newline at end of file +COMMUNITY_HOST=$COMMUNITY_HOST +WALLET_AUTH_PATH=$WALLET_AUTH_PATH +WALLET_LOGIN_PATH=$WALLET_LOGIN_PATH +GRAPHQL_PATH=$GRAPHQL_PATH +DEBUG_DISABLE_AUTH=false diff --git a/admin/src/config/index.js b/admin/src/config/index.js index fe373386d..10c75579a 100644 --- a/admin/src/config/index.js +++ b/admin/src/config/index.js @@ -7,7 +7,7 @@ const pkg = require('../../package') const constants = { CONFIG_VERSION: { DEFAULT: 'DEFAULT', - EXPECTED: 'v1.2022-03-18', + EXPECTED: 'v2.2024-01-04', CURRENT: '', }, } @@ -26,10 +26,18 @@ const environment = { PRODUCTION: process.env.NODE_ENV === 'production' || false, } +const COMMUNITY_HOST = process.env.COMMUNITY_HOST || undefined +const URL_PROTOCOL = process.env.URL_PROTOCOL || 'http' +const COMMUNITY_URL = + COMMUNITY_HOST && URL_PROTOCOL ? URL_PROTOCOL + '://' + COMMUNITY_HOST : undefined +const WALLET_URL = process.env.WALLET_URL || COMMUNITY_URL || 'http://localhost' + const endpoints = { - GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql', - WALLET_AUTH_URL: process.env.WALLET_AUTH_URL || 'http://localhost/authenticate?token={token}', - WALLET_URL: process.env.WALLET_URL || 'http://localhost/login', + GRAPHQL_URL: + (process.env.GRAPHQL_URL || COMMUNITY_URL || 'http://localhost:4000') + + process.env.GRAPHQL_PATH || '/graphql', + WALLET_AUTH_URL: WALLET_URL + (process.env.WALLET_AUTH_PATH || '/authenticate?token={token}'), + WALLET_LOGIN_URL: WALLET_URL + (process.env.WALLET_LOGIN_PATH || '/login'), } const debug = { diff --git a/admin/src/plugins/apolloProvider.js b/admin/src/plugins/apolloProvider.js index 8b02013f4..122857031 100644 --- a/admin/src/plugins/apolloProvider.js +++ b/admin/src/plugins/apolloProvider.js @@ -16,7 +16,7 @@ const authLink = new ApolloLink((operation, forward) => { return forward(operation).map((response) => { if (response.errors && response.errors[0].message === '403.13 - Client certificate revoked') { store.dispatch('logout', null) - window.location.assign(CONFIG.WALLET_URL) + window.location.assign(CONFIG.WALLET_LOGIN_URL) return response } const newToken = operation.getContext().response.headers.get('token') diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 9abc739fb..796bf4d46 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -1,7 +1,7 @@ # Need to adjust! COMMUNITY_NAME="Your community name" COMMUNITY_DESCRIPTION="Short Description from your Community." -COMMUNITY_URL=gddhost.tld +COMMUNITY_HOST=gddhost.tld COMMUNITY_SUPPORT_MAIL=support@supportmail.com # Need to adjust by updates @@ -9,7 +9,7 @@ COMMUNITY_SUPPORT_MAIL=support@supportmail.com DATABASE_CONFIG_VERSION=v1.2022-03-18 BACKEND_CONFIG_VERSION=v17.2023-07-03 FRONTEND_CONFIG_VERSION=v4.2022-12-20 -ADMIN_CONFIG_VERSION=v1.2022-03-18 +ADMIN_CONFIG_VERSION=v2.2024-01-04 FEDERATION_CONFIG_VERSION=v1.2023-01-09 FEDERATION_DHT_CONFIG_VERSION=v3.2023-04-26 @@ -40,10 +40,10 @@ WEBHOOK_GITHUB_BRANCH=master # frontend and admin paths, usually don't need changes # used in nginx config and for links in emails -WALLET_PATH=/login COMMUNITY_REGISTER_PATH=/register COMMUNITY_REDEEM_PATH=/redeem/{code} COMMUNITY_REDEEM_CONTRIBUTION_PATH=/redeem/CL-{code} +WALLET_LOGIN_PATH=/login WALLET_AUTH_PATH=/authenticate?token={token} EMAIL_LINK_VERIFICATION=/checkEmail/{optin}{code} EMAIL_LINK_SETPASSWORD=/reset-password/{optin} diff --git a/deployment/bare_metal/nginx/sites-available/gradido.conf.template b/deployment/bare_metal/nginx/sites-available/gradido.conf.template index 1b4732d7c..6b885a26a 100644 --- a/deployment/bare_metal/nginx/sites-available/gradido.conf.template +++ b/deployment/bare_metal/nginx/sites-available/gradido.conf.template @@ -1,5 +1,5 @@ server { - server_name $COMMUNITY_URL; + server_name $COMMUNITY_HOST; listen 80; listen [::]:80; diff --git a/deployment/bare_metal/nginx/sites-available/update-page.conf.template b/deployment/bare_metal/nginx/sites-available/update-page.conf.template index c26a705ce..e6cb51c7c 100644 --- a/deployment/bare_metal/nginx/sites-available/update-page.conf.template +++ b/deployment/bare_metal/nginx/sites-available/update-page.conf.template @@ -1,6 +1,6 @@ server { - server_name _; + server_name $COMMUNITY_HOST; listen 80; listen [::]:80;