From ebc772bf116f66af8efc67be55a34cb121d90986 Mon Sep 17 00:00:00 2001 From: Alex Garel Date: Fri, 2 Dec 2022 17:32:27 +0100 Subject: [PATCH] fix: nginx config allows app page reload (#141) we have to redirect unknown url to index.html so that react app can handle them --- backend/editor/settings.py | 2 +- conf/nginx.conf | 6 ++++++ docker/dev.yml | 11 +++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/editor/settings.py b/backend/editor/settings.py index 7f5e34b2..c6067462 100644 --- a/backend/editor/settings.py +++ b/backend/editor/settings.py @@ -4,5 +4,5 @@ import os uri = os.environ.get("NEO4J_URI", "bolt://localhost:7687") -access_token = os.environ.get("GITHUB_PAT", "") +access_token = os.environ.get("GITHUB_PAT") repo_uri = os.environ.get("REPO_URI", "openfoodfacts/openfoodfacts-server") diff --git a/conf/nginx.conf b/conf/nginx.conf index 3b307bbd..50f44106 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -68,6 +68,12 @@ server { index index.html; + location / { + # an unknown path is a path handled by react + try_files $uri $uri/ /index.html; + } + + } diff --git a/docker/dev.yml b/docker/dev.yml index 5d0f0393..a24b11c6 100644 --- a/docker/dev.yml +++ b/docker/dev.yml @@ -53,9 +53,8 @@ services: USER_UID: ${USER_UID:-1000} USER_GID: ${USER_GID:-1000} environment: - # disabling prod ui config and enabling node one - PROD_UI_SUFFIX: "-static" - DEV_UI_SUFFIX: "" - volumes: - # mount build folder dynamically - - ./taxonomy-editor-frontend/build:/opt/taxonomy-editor/build \ No newline at end of file + # by default, disabling prod ui config and enabling node one + # you can change this settings to try the prod configuration, + # by setting PROD_UI_SUFFIX to "" and DEV_UI_SUFFIX to "-dev" + PROD_UI_SUFFIX: "${PROD_UI_SUFFIX--static}" + DEV_UI_SUFFIX: "${DEV_UI_SUFFIX-}"