feat: added cors for web-player-backend

This commit is contained in:
Boris Cherepanov
2026-03-23 12:34:27 +03:00
parent f26135ca25
commit 310f0061d3
10 changed files with 323 additions and 39 deletions
+9 -9
View File
@@ -1,12 +1,12 @@
export type FurumiApiClient = (path: string) => Promise<unknown | null>
import axios from 'axios'
export function createFurumiApiClient(apiRoot: string): FurumiApiClient {
const API = apiRoot
const API_BASE = import.meta.env.VITE_API_BASE_URL ?? ''
export const API_ROOT = `${API_BASE}/api`
return async function api(path: string) {
const r = await fetch(API + path)
if (!r.ok) return null
return r.json()
}
}
const apiKey = import.meta.env.VITE_API_KEY
export const furumiApi = axios.create({
baseURL: API_ROOT,
headers: apiKey ? { 'x-api-key': apiKey } : {},
})