Skip to content

Commit

Permalink
Merge pull request #853 from amoutaux/add-env-var-for-backend
Browse files Browse the repository at this point in the history
feat(web): allow to configure proxy port through env var
  • Loading branch information
reglim authored Apr 30, 2024
2 parents b25e002 + f2ac7a1 commit 377a09e
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
base: '/',
plugins: [react()],
assetsInclude: ['**/*.md'],
server: {
port: 8080,
proxy: {
"/api": {
target: "http://localhost:5000",
changeOrigin: true,
secure: false,
},
"/doc": {
target: "http://localhost:5000",
changeOrigin: true,
secure: false,
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
return {
base: '/',
plugins: [react()],
assetsInclude: ['**/*.md'],
server: {
port: 8080,
proxy: {
'/api': {
target: 'http://localhost:' + `${env.VITE_PROXY_PORT ?? '5000'}`,
changeOrigin: true,
secure: false
},
'/doc': {
target: 'http://localhost:' + `${env.VITE_PROXY_PORT ?? '5000'}`,
changeOrigin: true,
secure: false
}
}
},
test: {
globals: true,
environment: 'jsdom',
css: true,
reporters: ['verbose'],
coverage: {
reporter: ['text', 'json', 'html'],
include: ['src/**/*'],
exclude: []
}
}
},
test: {
globals: true,
environment: 'jsdom',
css: true,
reporters: ['verbose'],
coverage: {
reporter: ['text', 'json', 'html'],
include: ['src/**/*'],
exclude: [],
}
}
})

0 comments on commit 377a09e

Please sign in to comment.