fix: configure frontend services for environment API URLs
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user