restore frontend session
This commit is contained in:
parent
24f437cac6
commit
bc62a25a8e
11 changed files with 146 additions and 14 deletions
17
frontend/website/src/utils/apiBase.ts
Normal file
17
frontend/website/src/utils/apiBase.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
function resolveApiBase(): string {
|
||||
const configuredApiUrl = import.meta.env.VITE_API_URL
|
||||
if (configuredApiUrl === '') {
|
||||
throw new Error('VITE_API_URL must be configured')
|
||||
}
|
||||
|
||||
if (!import.meta.env.DEV) {
|
||||
return configuredApiUrl
|
||||
}
|
||||
|
||||
const apiUrl = new URL(configuredApiUrl)
|
||||
apiUrl.hostname = window.location.hostname
|
||||
|
||||
return apiUrl.origin
|
||||
}
|
||||
|
||||
export const API_BASE = resolveApiBase()
|
||||
Loading…
Add table
Add a link
Reference in a new issue