Skip to content

Commit

Permalink
🔀 Merge pull request #21 from Importantus/hotfix-axios-backend-url
Browse files Browse the repository at this point in the history
🐛 Fix: the new backend url does not get set as axios base url
  • Loading branch information
Importantus authored Feb 3, 2024
2 parents e895715 + 3cf64c0 commit 6679db6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions frontend/src/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ instance.interceptors.request.use((config) => {
if (authStore.isLoggedIn) {
config.headers.Authorization = `Bearer ${authStore.token}`
}
config.baseURL = settingsStore.getBackendUrl()

return config
}, (error) => {
Expand Down
10 changes: 3 additions & 7 deletions frontend/src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const useSettingsStore = defineStore({
return undefined;
},
getRawBackendUrl(): string | undefined {
console.log("Using cached backend url");
return this.settings.backendUrl;
},
async fetchBackendUrl(): Promise<string> {
Expand All @@ -45,12 +44,9 @@ export const useSettingsStore = defineStore({
return loadedUrl;
},
setBackendUrl(url: string) {
const changed = this.settings.backendUrl !== url;
if (changed) {
this.settings.backendUrl = url;
this.updateSettings();
configuredAxios.defaults.baseURL = prepareBackendUrl(url);
}
this.settings.backendUrl = url;
this.updateSettings();
configuredAxios.defaults.baseURL = prepareBackendUrl(url);
},
applySettings() {
this.applyFontFactor();
Expand Down

0 comments on commit 6679db6

Please sign in to comment.