Add: use env proxy target vars
This commit is contained in:
parent
510fff3059
commit
11911efe35
2 changed files with 6 additions and 2 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -341,3 +341,4 @@ dump.rdb
|
|||
# Folders
|
||||
tmp/
|
||||
backend/media/
|
||||
media/
|
||||
|
|
|
@ -2,6 +2,9 @@ import path from 'path'
|
|||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
const proxyTargetAPI = process.env.VITE_PROXY_TARGET_API || 'http://localhost:8080';
|
||||
const proxyTargetMedia = process.env.VITE_PROXY_TARGET_MEDIA || proxyTargetAPI;
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
|
@ -13,12 +16,12 @@ export default defineConfig({
|
|||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://localhost:8080',
|
||||
target: proxyTargetAPI,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
'/media': {
|
||||
target: 'http://localhost:8080',
|
||||
target: proxyTargetMedia,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue