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
|
# Folders
|
||||||
tmp/
|
tmp/
|
||||||
backend/media/
|
backend/media/
|
||||||
|
media/
|
||||||
|
|
|
@ -2,6 +2,9 @@ import path from 'path'
|
||||||
import { defineConfig } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import react from '@vitejs/plugin-react'
|
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/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [react()],
|
plugins: [react()],
|
||||||
|
@ -13,12 +16,12 @@ export default defineConfig({
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: 'http://localhost:8080',
|
target: proxyTargetAPI,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
'/media': {
|
'/media': {
|
||||||
target: 'http://localhost:8080',
|
target: proxyTargetMedia,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
secure: false,
|
secure: false,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue