Skip to content

Commit b010666

Browse files
committed
fix: update frontend API URL for production
1 parent 794e35e commit b010666

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

frontend/js/api.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
const API_URL = 'http://localhost:5000/api';
1+
const API_BASE_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
2+
? 'http://localhost:5000'
3+
: 'https://logitrack-ppnc.onrender.com';
4+
5+
const API_URL = `${API_BASE_URL}/api`;
26

37
const api = {
48
getHeaders: () => {

frontend/js/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ document.addEventListener('DOMContentLoaded', function () {
88
const backToWelcomeBtn = document.getElementById('back-to-welcome');
99
const backToWelcomeBtn2 = document.getElementById('back-to-welcome-2');
1010

11-
const API_URL = 'http://localhost:5000/api/auth';
11+
const API_BASE_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
12+
? 'http://localhost:5000'
13+
: 'https://logitrack-ppnc.onrender.com';
14+
15+
const API_URL = `${API_BASE_URL}/api/auth`;
1216

1317
let loginDestination = 'dashboard'; // Default
1418

0 commit comments

Comments
 (0)