Add: use env proxy target vars

This commit is contained in:
Aroy-Art 2025-04-04 09:39:51 +02:00
parent 510fff3059
commit 11911efe35
Signed by: Aroy
GPG key ID: 583642324A1D2070
2 changed files with 6 additions and 2 deletions

1
.gitignore vendored
View file

@ -341,3 +341,4 @@ dump.rdb
# Folders # Folders
tmp/ tmp/
backend/media/ backend/media/
media/

View file

@ -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,
}, },