Skip to content

Commit

Permalink
🔧(frontend) pass host and port through environment vars
Browse files Browse the repository at this point in the history
Configured the frontend to use environment variables (prefixed with "VITE_") for frontend
port and host configuration, which will be overridden in the Helm chart values
to ensure correct values are used in different environments.

Helm requires the frontend port to be 8081 and use the public host,
not the default "localhost" value.
  • Loading branch information
lebaudantoine committed Jul 2, 2024
1 parent 29a9b52 commit 35ebc5a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
16 changes: 16 additions & 0 deletions src/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.14.9",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "7.13.1",
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmit": true
"noEmit": true,
"types": ["node"]
},
"include": ["vite.config.ts"]
}
16 changes: 10 additions & 6 deletions src/frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
export default defineConfig(({mode}) => {
const env = loadEnv(mode, process.cwd());
return {
plugins: [react()],
server: {
port: parseInt(env.VITE_PORT) || 3000,
host: env.VITE_HOST || 'localhost',
},
}
})

0 comments on commit 35ebc5a

Please sign in to comment.