fix: change API URL helpers to use relative routing in production regardless of port
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# 🚀 Complete Bluehost Ubuntu 24.04 VPS Hosting Guide for Freshers-Hub
|
||||
# 🚀 Complete Bluehost Ubuntu 24.04 VPS Hosting Guide for Freshers-Hub
|
||||
|
||||
This guide provides a step-by-step walkthrough for deploying the entire **Freshers-Hub** project on a **Bluehost Ubuntu 24.04 VPS**.
|
||||
|
||||
|
||||
@@ -27,9 +27,8 @@ export const getBackendUrl = (path: string = ''): string => {
|
||||
return `${envUrl.endsWith('/') ? envUrl.slice(0, -1) : envUrl}${path}`;
|
||||
}
|
||||
const host = window.location.hostname;
|
||||
const port = window.location.port;
|
||||
// If running in production behind Nginx reverse proxy (standard port 80/443 or empty)
|
||||
if (!port || port === '80' || port === '443') {
|
||||
// If running in production build, always use relative routing
|
||||
if (import.meta.env.PROD) {
|
||||
return path;
|
||||
}
|
||||
return `http://${host}:8085${path}`;
|
||||
@@ -41,9 +40,8 @@ export const getChatbotUrl = (path: string = ''): string => {
|
||||
return `${envUrl.endsWith('/') ? envUrl.slice(0, -1) : envUrl}${path}`;
|
||||
}
|
||||
const host = window.location.hostname;
|
||||
const port = window.location.port;
|
||||
// If running in production behind Nginx reverse proxy (standard port 80/443 or empty)
|
||||
if (!port || port === '80' || port === '443') {
|
||||
// If running in production build, always use relative routing
|
||||
if (import.meta.env.PROD) {
|
||||
return path.startsWith('/api/chat') ? path : `/api/chat${path}`;
|
||||
}
|
||||
return `http://${host}:8081${path}`;
|
||||
|
||||
Reference in New Issue
Block a user