From 9cc299a80cd7a274d91bab34d7c0421f6bba8839 Mon Sep 17 00:00:00 2001 From: simonredfern Date: Tue, 10 Dec 2024 13:49:32 +0100 Subject: [PATCH] docfix/Adding notes and debug settings to help diagnose session storage problems which can cause issues with login --- .env.example | 3 +++ Dockerfiles/prestart.go | 1 + README.md | 31 +++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/.env.example b/.env.example index 43ca60b..f3f7fd8 100644 --- a/.env.example +++ b/.env.example @@ -36,3 +36,6 @@ VITE_CHATBOT_URL=http://localhost:5000 # https://nodejs.org/en/learn/getting-started/nodejs-the-difference-between-development-and-production # The value could be: development, staging, production # NODE_ENV=development + +# If you have a problem with session storage (which will cause problems with login) you can enable this. See README for further info. +#DEBUG=express-session diff --git a/Dockerfiles/prestart.go b/Dockerfiles/prestart.go index e3b0be3..f0b236e 100644 --- a/Dockerfiles/prestart.go +++ b/Dockerfiles/prestart.go @@ -10,6 +10,7 @@ import ( ) func main() { + // Define the host env variables to be replaced at build time config := []string{"VITE_OBP_API_HOST", "VITE_OBP_API_MANAGER_HOST", "VITE_OBP_API_PORTAL_HOST"} configMap := make(map[string]string) diff --git a/README.md b/README.md index 89976fb..1b8b647 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,37 @@ server { } ``` +Note: if you have issues with session stickyness / login issues, enable #DEBUG=express-session in your .env +and if you see messages like these in the log, + +``` +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session no SID sent, generating session +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session saving 5JIW_dx9CG8qs0OK4iv7Pn2Kg2huZuvQ +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session not secured +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session split response +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session saving -yf0uzAZf5mP9JVYov9oMR7CxQLnO4wm +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session not secured +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session no SID sent, generating session +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session saving nballQYMYZRn_HG0enM2RIPdv7GAdzJc +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session not secured +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session no SID sent, generating session +Dec 10 12:26:18 obp-sandbox node[1060160]: Tue, 10 Dec 2024 12:26:18 GMT express-session no SID sent, generating session + +``` + +then make sure your NGINX config includes the $scheme: + +``` + +proxy_set_header X-Real-IP $remote_addr; +proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +proxy_set_header X-Forwarded-Proto $scheme; + +``` + +so that Node knows that the cookies have been sent securely over https. + + # LICENSE This project is licensed under the AGPL V3 (see NOTICE) and a commercial license from TESOBE.