fix: change API URL helpers to use relative routing in production regardless of port

This commit is contained in:
Shanmuga Krishnan S M
2026-08-03 12:49:06 +05:30
parent ab759e37fd
commit c6915b6c83
2 changed files with 5 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
# 🚀 Complete Bluehost Ubuntu 24.04 VPS Hosting Guide for Freshers-Hub
![alt text](image.png)# 🚀 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**.

View File

@@ -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}`;