mirror of
https://github.com/ets-cfuhrman-pfe/EvalueTonSavoir.git
synced 2025-08-11 21:23:54 -04:00
Merge pull request #161 from ets-cfuhrman-pfe/ssl-changes
Change the way the back-end url is set to a socket url
This commit is contained in:
commit
c754d71623
6 changed files with 9 additions and 7 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -73,7 +73,7 @@ web_modules/
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
|
|
||||||
# dotenv environment variable files
|
# dotenv environment variable files
|
||||||
.env
|
server/.env
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
**/node_modules
|
**/node_modules
|
||||||
.env
|
|
||||||
2
client/.env
Normal file
2
client/.env
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
VITE_BACKEND_URL=http://localhost:4400
|
||||||
|
VITE_AZURE_BACKEND_URL=http://localhost:4400
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// constants.tsx
|
// constants.tsx
|
||||||
const ENV_VARIABLES = {
|
const ENV_VARIABLES = {
|
||||||
MODE: 'production',
|
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}`);
|
console.log(`ENV_VARIABLES.VITE_BACKEND_URL=${ENV_VARIABLES.VITE_BACKEND_URL}`);
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,10 @@ class WebSocketService {
|
||||||
connect(backendUrl: string): Socket {
|
connect(backendUrl: string): Socket {
|
||||||
console.log(`WebSocketService.connect(${backendUrl})`);
|
console.log(`WebSocketService.connect(${backendUrl})`);
|
||||||
|
|
||||||
// Ensure the URL uses wss: if the page is loaded over https:
|
// Ensure the URL uses wss: if the URL starts with https:
|
||||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const protocol = backendUrl.startsWith('https:') ? 'wss:' : 'ws:';
|
||||||
const url = backendUrl.replace(/^http:/, protocol);
|
console.log(`WebSocketService.connect: protocol=${protocol}`);
|
||||||
|
const url = backendUrl.replace(/^http(s):/, protocol);
|
||||||
console.log(`WebSocketService.connect: changed url=${url}`);
|
console.log(`WebSocketService.connect: changed url=${url}`);
|
||||||
|
|
||||||
this.socket = io(url, {
|
this.socket = io(url, {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
"module": "ES2020",
|
"module": "ESNext",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
|
|
||||||
/* Bundler mode */
|
/* Bundler mode */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue