Skip to content

Commit

Permalink
Merge pull request #135 from marvin-wtt/feat/dev-proxy
Browse files Browse the repository at this point in the history
feat: Use dev proxy
  • Loading branch information
marvin-wtt authored Nov 17, 2024
2 parents d63a152 + 24311a5 commit 992126c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 6 additions & 0 deletions frontend/quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ export default configure((ctx) => {
devServer: {
// https: true
open: true, // opens browser window automatically

proxy: {
'/api': {
target: 'http://localhost:3000',
},
},
},

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/boot/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ declare module '@vue/runtime-core' {
}
}

// Resolve url depending on environment
const apiUrl =
window.location.hostname === 'localhost'
? 'http://localhost:3000'
: window.origin;

// Be careful when using SSR for cross-request state pollution
// due to creating a Singleton instance here;
// If any client changes this (global) instance, it might be a
// good idea to move this instance creation inside the
// "export default () => {}" function below (which runs individually
// for each client)
const api = axios.create({
baseURL: `${apiUrl}/api/v1/`,
baseURL: `${window.origin}/api/v1/`,
// Needed for auth
withCredentials: true,
});
Expand Down

0 comments on commit 992126c

Please sign in to comment.