Amend Upstream URL
This commit is contained in:
10
src/main.ts
10
src/main.ts
@@ -139,8 +139,16 @@ router.beforeEach(async (to) => {
|
||||
app.use(router);
|
||||
app.use(ToastService)
|
||||
|
||||
let apiUrl = getApiUrl();
|
||||
|
||||
if (!apiUrl) {
|
||||
apiUrl = `http://${apiUrl}`
|
||||
} else {
|
||||
apiUrl = ''
|
||||
}
|
||||
|
||||
const axiosInstance = axios.create({
|
||||
baseURL: getApiUrl() ?? '',
|
||||
baseURL: apiUrl,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export interface AppConfig {
|
||||
API_BASE_URL: string;
|
||||
API_HOST: string;
|
||||
API_PORT: number;
|
||||
}
|
||||
|
||||
let runtimeConfig: AppConfig = {
|
||||
API_BASE_URL: import.meta.env.VITE_API_BASE_URL || '',
|
||||
API_PORT: import.meta.env.VITE_API_BASE_URL || 8080
|
||||
API_HOST: import.meta.env.VITE_API_HOST || '',
|
||||
API_PORT: import.meta.env.VITE_API_PORT || 8080
|
||||
};
|
||||
|
||||
export function initConfig(config: Partial<AppConfig>) {
|
||||
@@ -20,8 +20,8 @@ export function getConfig(): AppConfig {
|
||||
}
|
||||
|
||||
export function getApiUrl() {
|
||||
if (!runtimeConfig.API_BASE_URL) {
|
||||
if (!runtimeConfig.API_HOST) {
|
||||
return null;
|
||||
}
|
||||
return `${runtimeConfig.API_BASE_URL}:${runtimeConfig.API_PORT}`;
|
||||
return `${runtimeConfig.API_HOST}:${runtimeConfig.API_PORT}`;
|
||||
}
|
||||
Reference in New Issue
Block a user