chore(dev): Better support reverse proxy in dev mode (#1974)

This commit is contained in:
Rémi Marseault 2024-10-18 09:21:52 +02:00 committed by GitHub
parent baf79612fd
commit 76fb79ee69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 11 deletions

View file

@ -1,8 +1,5 @@
VITE_QBITTORRENT_TARGET='http://localhost'
VITE_QBITTORRENT_PORT=8080
VITE_BACKEND_TARGET='http://localhost'
VITE_BACKEND_PORT=8081
VITE_QBITTORRENT_TARGET=http://localhost:8080
VITE_BACKEND_TARGET=http://localhost:8081
VITE_USE_MOCK_PROVIDER=false
VITE_FAKE_TORRENTS_COUNT=5

View file

@ -9,10 +9,8 @@ import vuetify from 'vite-plugin-vuetify'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
const qBittorrentHost = env.VITE_QBITTORRENT_TARGET ?? 'http://127.0.0.1'
const qBittorrentPort = env.VITE_QBITTORRENT_PORT ?? '8080'
const backendHost = env.VITE_BACKEND_HOST ?? 'http://127.0.0.1'
const backendPort = env.VITE_BACKEND_PORT ?? '3000'
const qBittorrentTarget = env.VITE_QBITTORRENT_TARGET ?? 'http://localhost:8080'
const backendTarget = env.VITE_BACKEND_TARGET ?? 'http://localhost:3000'
return {
base: './',
@ -53,11 +51,13 @@ export default defineConfig(({ mode }) => {
proxy: {
'/api': {
secure: false,
target: `${qBittorrentHost}:${qBittorrentPort}`
changeOrigin: true,
target: qBittorrentTarget
},
'/backend': {
secure: false,
target: `${backendHost}:${backendPort}`
changeOrigin: true,
target: backendTarget
}
}
},