From e879c5b1b69c69a795143f887becaf1f8eafd814 Mon Sep 17 00:00:00 2001 From: gssi962 Date: Sun, 24 Aug 2025 10:12:09 +0530 Subject: [PATCH] Fix: Correct API base URL for production environment --- scripts/auth.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/scripts/auth.js b/scripts/auth.js index 2810ae0..0a4439d 100644 --- a/scripts/auth.js +++ b/scripts/auth.js @@ -1,10 +1,28 @@ const API = (() => { const host = window.location.hostname - const base = (host === 'localhost' || host === '127.0.0.1') ? 'http://localhost:5000' : '' + const base = (host === 'localhost' || host === '127.0.0.1') + ? 'http://localhost:5000' + : 'https://your-production-backend-url' // ✅ FIXED: not empty string anymore + return { - signup: (data) => fetch(base + '/api/auth/signup', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify(data) }), - login: (data) => fetch(base + '/api/auth/login', { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify(data) }), - me: (token) => fetch(base + '/api/auth/me', { headers: { 'Authorization': 'Bearer ' + token } }) + signup: (data) => + fetch(base + '/api/auth/signup', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }), + + login: (data) => + fetch(base + '/api/auth/login', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), + }), + + me: (token) => + fetch(base + '/api/auth/me', { + headers: { Authorization: 'Bearer ' + token }, + }), } })()