fix dynamic env
This commit is contained in:
parent
a798d2f729
commit
7c2a38788b
@ -5,6 +5,8 @@
|
||||
<link rel="icon" type="image/png" href="/src/assets/icons/logo.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Dating App</title>
|
||||
<!-- Load environment variables before app starts -->
|
||||
<script src="/env.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
3
frontend/public/env.js
Normal file
3
frontend/public/env.js
Normal file
@ -0,0 +1,3 @@
|
||||
window.__ENV__ = {
|
||||
API_BASE: "http://localhost:8000"
|
||||
};
|
||||
3
frontend/public/env.js.template
Normal file
3
frontend/public/env.js.template
Normal file
@ -0,0 +1,3 @@
|
||||
window.__ENV__ = {
|
||||
API_BASE: "${API_BASE:-http://localhost:8000}"
|
||||
};
|
||||
@ -1,7 +1,7 @@
|
||||
import axios from 'axios'
|
||||
|
||||
// Get API base URL from environment or default
|
||||
const API_BASE_URL = import.meta.env.VITE_API_URL || 'http://localhost:8000'
|
||||
// Get API base URL from runtime environment (window.__ENV__) or build-time env
|
||||
const API_BASE_URL = window.__ENV__?.API_BASE || import.meta.env.VITE_API_URL || 'http://localhost:8000'
|
||||
|
||||
// Create axios instance with default config
|
||||
const api = axios.create({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user