diff --git a/.gitignore b/.gitignore index ae7f632..6e8de7b 100644 --- a/.gitignore +++ b/.gitignore @@ -73,7 +73,7 @@ web_modules/ .yarn-integrity # dotenv environment variable files -.env +server/.env .env.development.local .env.test.local .env.production.local diff --git a/client/.dockerignore b/client/.dockerignore index fb664ef..cf70988 100644 --- a/client/.dockerignore +++ b/client/.dockerignore @@ -1,2 +1 @@ **/node_modules -.env \ No newline at end of file diff --git a/client/.env b/client/.env new file mode 100644 index 0000000..fa03bbb --- /dev/null +++ b/client/.env @@ -0,0 +1,2 @@ +VITE_BACKEND_URL=http://localhost:4400 +VITE_AZURE_BACKEND_URL=http://localhost:4400 diff --git a/client/src/constants.tsx b/client/src/constants.tsx index 032e68e..21ff020 100644 --- a/client/src/constants.tsx +++ b/client/src/constants.tsx @@ -1,7 +1,7 @@ // constants.tsx const ENV_VARIABLES = { MODE: 'production', - VITE_BACKEND_URL: import.meta.env.VITE_BACKEND_URL || "" + VITE_BACKEND_URL: process.env.VITE_BACKEND_URL || "" }; console.log(`ENV_VARIABLES.VITE_BACKEND_URL=${ENV_VARIABLES.VITE_BACKEND_URL}`); diff --git a/client/src/services/WebsocketService.tsx b/client/src/services/WebsocketService.tsx index 1ee91fb..8ba0da2 100644 --- a/client/src/services/WebsocketService.tsx +++ b/client/src/services/WebsocketService.tsx @@ -23,9 +23,10 @@ class WebSocketService { connect(backendUrl: string): Socket { console.log(`WebSocketService.connect(${backendUrl})`); - // Ensure the URL uses wss: if the page is loaded over https: - const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; - const url = backendUrl.replace(/^http:/, protocol); + // Ensure the URL uses wss: if the URL starts with https: + const protocol = backendUrl.startsWith('https:') ? 'wss:' : 'ws:'; + console.log(`WebSocketService.connect: protocol=${protocol}`); + const url = backendUrl.replace(/^http(s):/, protocol); console.log(`WebSocketService.connect: changed url=${url}`); this.socket = io(url, { diff --git a/client/tsconfig.json b/client/tsconfig.json index c9c40d8..5324e80 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -3,7 +3,7 @@ "target": "ESNext", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ES2020", + "module": "ESNext", "skipLibCheck": true, /* Bundler mode */