feat: add environment configuration files and update API base URL handling for production
This commit is contained in:
@@ -12,7 +12,15 @@ export class BaseApiClient implements ApiClient {
|
||||
}
|
||||
|
||||
private buildURL(endpoint: string, params?: Record<string, string | number | boolean | undefined>): string {
|
||||
const url = new URL(endpoint, this.baseURL)
|
||||
let url: URL
|
||||
|
||||
if (this.baseURL) {
|
||||
// Full base URL provided
|
||||
url = new URL(endpoint, this.baseURL)
|
||||
} else {
|
||||
// Use relative URL (for reverse proxy)
|
||||
url = new URL(endpoint, window.location.origin)
|
||||
}
|
||||
|
||||
if (params) {
|
||||
Object.entries(params).forEach(([key, value]) => {
|
||||
@@ -22,7 +30,7 @@ export class BaseApiClient implements ApiClient {
|
||||
})
|
||||
}
|
||||
|
||||
return url.toString()
|
||||
return this.baseURL ? url.toString() : url.pathname + url.search
|
||||
}
|
||||
|
||||
private async request<T>(
|
||||
|
||||
Reference in New Issue
Block a user