From 10f1194abd7c0a0e15f03c93a85938a01a5c1dab Mon Sep 17 00:00:00 2001 From: Sacha Bron Date: Sun, 18 Aug 2024 02:26:57 +0200 Subject: [PATCH] Hotfix dev mode --- client/.env.development | 1 + client/src/axios-common.ts | 5 ++++- client/src/ws.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/.env.development b/client/.env.development index e69de29..89c6524 100644 --- a/client/.env.development +++ b/client/.env.development @@ -0,0 +1 @@ +VITE_ORBITAL_SERVER_URL=http://localhost:3000 \ No newline at end of file diff --git a/client/src/axios-common.ts b/client/src/axios-common.ts index 51a6d40..3eb58b5 100644 --- a/client/src/axios-common.ts +++ b/client/src/axios-common.ts @@ -1,7 +1,10 @@ import { Axios } from "axios"; +console.log(import.meta.env.DEV); +console.log(import.meta.env.VITE_ORBITAL_SERVER_URL); + export const axiosInstance = new Axios({ - baseURL: window.location.href ?? "", + baseURL: import.meta.env.DEV ? import.meta.env.VITE_ORBITAL_SERVER_URL ?? "" : window.location.href, transformRequest: (data) => JSON.stringify(data), headers: { "Content-Type": "application/json", diff --git a/client/src/ws.ts b/client/src/ws.ts index de7c261..b5d73a1 100644 --- a/client/src/ws.ts +++ b/client/src/ws.ts @@ -25,7 +25,7 @@ export const WebSocketHandler = { } console.log("Starting connection to WebSocket Server"); - const wsUrl = new URL(window.location.href); + const wsUrl = import.meta.env.DEV ? new URL(import.meta.env.SERVER_URL) : new URL(window.location.href); // const wsProtocol = window.location.protocol === "https:" ? "wss://" : "ws://"; // export const ws = new WebSocket(wsProtocol + location.host + "/");