diff --git a/client/src/index.js b/client/src/index.js index d098496..4b13194 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -4,7 +4,7 @@ let USER = false export async function getLoggedUser() { if (USER === false) { console.log('Caching user data...') - USER = await (await fetch('/api/user')).json() + USER = await (await fetch(`${import.meta.env.BASE_URL}/api/user`)).json() } return USER @@ -16,7 +16,9 @@ export function createRoomEventStream(roomId) { export const Database = { async getSeats(roomId) { - const seatList = await (await fetch(`/api/room/seats?id=${roomId}`)).json() + const seatList = await ( + await fetch(`${import.meta.env.BASE_URL}/api/room/seats?id=${roomId}`) + ).json() const seats = {} seatList.forEach(seat => { @@ -26,7 +28,9 @@ export const Database = { return seats }, async occupySeat(seatId) { - const response = await fetch(`/api/seat/occupy?id=${seatId}`, { method: 'POST' }) + const response = await fetch(`${import.meta.env.BASE_URL}/api/seat/occupy?id=${seatId}`, { + method: 'POST', + }) if (!response.ok) { throw new Error(await response.text()) @@ -35,7 +39,9 @@ export const Database = { await response.json() }, async leaveSeat(seatId) { - const response = await fetch(`/api/seat/leave?id=${seatId}`, { method: 'POST' }) + const response = await fetch(`${import.meta.env.BASE_URL}/api/seat/leave?id=${seatId}`, { + method: 'POST', + }) if (!response.ok) { throw new Error(await response.text()) diff --git a/client/src/pages/index.js b/client/src/pages/index.js index 54809c5..76f1ffb 100644 --- a/client/src/pages/index.js +++ b/client/src/pages/index.js @@ -15,7 +15,7 @@ const elLogoutButton = document.querySelector('#logout-button') const elRoomGrid = document.querySelector('.room-grid') async function logout() { - await fetch('/api/logout', { method: 'POST' }) + await fetch(`${import.meta.env.BASE_URL}/api/logout`, { method: 'POST' }) location.href = '/' } diff --git a/client/src/pages/login.js b/client/src/pages/login.js index 56d49dd..cca406a 100644 --- a/client/src/pages/login.js +++ b/client/src/pages/login.js @@ -33,7 +33,7 @@ function displayErrorString(e) { async function login() { try { - const response = await fetch('/api/login', { + const response = await fetch(`${import.meta.env.BASE_URL}/api/login`, { method: 'POST', headers: { Accept: 'application/json, text/plain, */*',