We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 19e534b commit 33f1e28Copy full SHA for 33f1e28
1 file changed
frontend/src/api/axios.ts
@@ -1,6 +1,21 @@
1
import axios from 'axios';
2
3
-const API_URL = process.env.REACT_APP_API_URL || 'http://localhost:8082/api';
+// In production, use relative URL (nginx proxies /api to backend)
4
+// In development, use localhost with explicit port
5
+const getApiUrl = () => {
6
+ if (process.env.REACT_APP_API_URL) {
7
+ return process.env.REACT_APP_API_URL;
8
+ }
9
+ // Check if we're in production (served from a domain, not localhost dev server)
10
+ if (typeof window !== 'undefined' &&
11
+ window.location.hostname !== 'localhost' &&
12
+ window.location.hostname !== '127.0.0.1') {
13
+ return '/api';
14
15
+ return 'http://localhost:8082/api';
16
+};
17
+
18
+const API_URL = getApiUrl();
19
20
const axiosInstance = axios.create({
21
baseURL: API_URL,
0 commit comments