From c6915b6c8310cb0a546d8ec2cadbf1b1328ab8fb Mon Sep 17 00:00:00 2001 From: Shanmuga Krishnan S M Date: Mon, 3 Aug 2026 12:49:06 +0530 Subject: [PATCH] fix: change API URL helpers to use relative routing in production regardless of port --- BLUEHOST_VPS_DEPLOYMENT_GUIDE.md | 2 +- src/lib/utils.ts | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/BLUEHOST_VPS_DEPLOYMENT_GUIDE.md b/BLUEHOST_VPS_DEPLOYMENT_GUIDE.md index 02d27f8..7b396cf 100644 --- a/BLUEHOST_VPS_DEPLOYMENT_GUIDE.md +++ b/BLUEHOST_VPS_DEPLOYMENT_GUIDE.md @@ -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**. diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 5f6a038..29ea144 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -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}`;