fix: configure frontend services for environment API URLs

This commit is contained in:
2026-08-17 12:27:14 +00:00
parent 09e6c86ca0
commit 3e12fa2d01
5 changed files with 20 additions and 11 deletions

View File

@@ -1,3 +1,7 @@
const API_URL = import.meta.env.VITE_API_URL || ''
const BASE = `${API_URL}/api/game`
function apiError(message, status) {
const err = new Error(message)
err.status = status
@@ -6,7 +10,7 @@ function apiError(message, status) {
export async function myGainsApi() {
const token = localStorage.getItem('token')
const res = await fetch('/api/game/my-gains', {
const res = await fetch(`${BASE}/my-gains`, {
headers: { Authorization: `Bearer ${token}` },
})
const data = await res.json()
@@ -16,7 +20,7 @@ export async function myGainsApi() {
export async function participateApi(code) {
const token = localStorage.getItem('token')
const res = await fetch('/api/game/participate', {
const res = await fetch(`${BASE}/participate`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',