feat(vite): add server proxy to handle CORS for API requests

This commit is contained in:
InfinityPacer
2024-10-10 15:41:02 +08:00
parent 505773043b
commit 54046a4717
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -1,2 +1,2 @@
VITE_API_BASE_URL=http://localhost:3001/api/v1/ VITE_API_BASE_URL=/api/v1/
VITE_PUBLIC_VAPID_KEY=BH3w49sZA6jXUnE-yt4jO6VKh73lsdsvwoJ6Hx7fmPIDKoqGiUl2GEoZzy-iJfn4SfQQcx7yQdHf9RknwrL_lSM VITE_PUBLIC_VAPID_KEY=BH3w49sZA6jXUnE-yt4jO6VKh73lsdsvwoJ6Hx7fmPIDKoqGiUl2GEoZzy-iJfn4SfQQcx7yQdHf9RknwrL_lSM
+10
View File
@@ -151,4 +151,14 @@ export default defineConfig({
exclude: ['vuetify'], exclude: ['vuetify'],
entries: ['./src/**/*.vue'], entries: ['./src/**/*.vue'],
}, },
server: {
proxy: {
'/api/v1': {
target: 'http://localhost:3001',
changeOrigin: true,
secure: false,
cookieDomainRewrite: 'localhost',
},
},
},
}) })