diff --git a/README.md b/README.md index bffe3a9..85a2eb0 100644 --- a/README.md +++ b/README.md @@ -51,10 +51,9 @@ Navigate into the frontend cd client ``` -Create a .env file containing the following variables - +Create a .env file in the `client` folder containing the following variables: ```sh -PUBLIC_API_URL=http://0.0.0.0:3000/ +PUBLIC_API_URL=http://0.0.0.0:3000 PUBLIC_WEBSOCKET_URL=ws://localhost:3000 ``` diff --git a/client/src/routes/+page.svelte b/client/src/routes/+page.svelte index d77cc54..28e9951 100644 --- a/client/src/routes/+page.svelte +++ b/client/src/routes/+page.svelte @@ -24,7 +24,11 @@ const reload = () => { toast.success("Reloaded rooms") - invalidate(`${env.PUBLIC_API_URL}/rooms`); + let url = `${env.PUBLIC_API_URL}`; + if (url.endsWith("/")) { + url = url.slice(0, -1); + } + invalidate(`${url}/rooms`); } diff --git a/client/src/routes/+page.ts b/client/src/routes/+page.ts index f678510..b73fb26 100644 --- a/client/src/routes/+page.ts +++ b/client/src/routes/+page.ts @@ -3,7 +3,11 @@ import {env} from "$env/dynamic/public"; export const load: PageLoad = async ({fetch}) => { try { - const res = await fetch(`${env.PUBLIC_API_URL}/rooms`); + let url = `${env.PUBLIC_API_URL}`; + if (url.endsWith("/")) { + url = url.slice(0, -1); + } + const res = await fetch(`${url}/rooms`); return await res.json(); } catch (e) { return {