From 4efbd49c728c55693f1e10e79d7ada4822f1ae98 Mon Sep 17 00:00:00 2001 From: kenilkb Date: Fri, 10 Jul 2026 19:05:29 +0530 Subject: [PATCH] configure_vite_proxy_and_relative_api_urls_for_ngrok_compatibility --- Channel-Backend/src/app.ts | 2 +- .../src/components/ui/DocumentPreviewModal.tsx | 2 +- .../src/pages/ClientAgreementsPage.tsx | 2 +- Channel-Frontend/src/pages/InvitePage.tsx | 2 +- Channel-Frontend/src/pages/OnboardingPage.tsx | 2 +- .../src/pages/admin/LegalTemplatesPage.tsx | 2 +- Channel-Frontend/src/services/axios.ts | 2 +- Channel-Frontend/vite.config.ts | 14 +++++++++++++- 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Channel-Backend/src/app.ts b/Channel-Backend/src/app.ts index 3ec89a6..6027189 100644 --- a/Channel-Backend/src/app.ts +++ b/Channel-Backend/src/app.ts @@ -28,7 +28,7 @@ app.use(helmet({ useDefaults: false, directives: { "default-src": helmet.contentSecurityPolicy.dangerouslyDisableDefaultSrc, - "frame-ancestors": ["'self'", "http://localhost:5173", "http://localhost:5000"], + "frame-ancestors": ["'self'", "http://localhost:5173", "http://localhost:5000", "https://*.ngrok-free.dev", "https://*.ngrok.io"], }, }, frameguard: false, diff --git a/Channel-Frontend/src/components/ui/DocumentPreviewModal.tsx b/Channel-Frontend/src/components/ui/DocumentPreviewModal.tsx index 6a28863..e637c07 100644 --- a/Channel-Frontend/src/components/ui/DocumentPreviewModal.tsx +++ b/Channel-Frontend/src/components/ui/DocumentPreviewModal.tsx @@ -210,7 +210,7 @@ export const DocumentPreviewModal: React.FC = ({ }; const fileHost = ( - import.meta.env.VITE_API_URL || "http://localhost:5000/api/v1" + import.meta.env.VITE_API_URL || "/api/v1" ).replace("/api/v1", ""); const isBothVerified = verifiedDocs.nda && verifiedDocs.msa; const isCurrentVerified = diff --git a/Channel-Frontend/src/pages/ClientAgreementsPage.tsx b/Channel-Frontend/src/pages/ClientAgreementsPage.tsx index 18c917a..9b7265b 100644 --- a/Channel-Frontend/src/pages/ClientAgreementsPage.tsx +++ b/Channel-Frontend/src/pages/ClientAgreementsPage.tsx @@ -15,7 +15,7 @@ export const ClientAgreementsPage: React.FC = () => { const ndaAcceptance = acceptances?.find(a => a.document.type === 'NDA'); const msaAcceptance = acceptances?.find(a => a.document.type === 'MSA'); - const fileHost = (import.meta.env.VITE_API_URL || 'http://localhost:5000/api/v1').replace('/api/v1', ''); + const fileHost = (import.meta.env.VITE_API_URL || '/api/v1').replace('/api/v1', ''); // Header component const headerNode = ( diff --git a/Channel-Frontend/src/pages/InvitePage.tsx b/Channel-Frontend/src/pages/InvitePage.tsx index 0fe1f91..cbbc8e5 100644 --- a/Channel-Frontend/src/pages/InvitePage.tsx +++ b/Channel-Frontend/src/pages/InvitePage.tsx @@ -31,7 +31,7 @@ export const InvitePage: React.FC = () => { const validateToken = async () => { try { - const response = await axios.get(`${import.meta.env.VITE_API_URL || 'http://localhost:5000/api/v1'}/auth/invite/${token}`); + const response = await axiosInstance.get(`/auth/invite/${token}`); setEmail(response.data.email); setStatus('valid'); } catch (err) { diff --git a/Channel-Frontend/src/pages/OnboardingPage.tsx b/Channel-Frontend/src/pages/OnboardingPage.tsx index e521d9a..0c77a1c 100644 --- a/Channel-Frontend/src/pages/OnboardingPage.tsx +++ b/Channel-Frontend/src/pages/OnboardingPage.tsx @@ -90,7 +90,7 @@ export const OnboardingPage: React.FC = () => { }; const renderDocumentViewer = (type: DocumentType) => { - const fileHost = (import.meta.env.VITE_API_URL || 'http://localhost:5000/api/v1').replace('/api/v1', ''); + const fileHost = (import.meta.env.VITE_API_URL || '/api/v1').replace('/api/v1', ''); const pdfUrl = type === 'NDA' ? ndaPdfUrl : msaPdfUrl; if (pdfUrl) { diff --git a/Channel-Frontend/src/pages/admin/LegalTemplatesPage.tsx b/Channel-Frontend/src/pages/admin/LegalTemplatesPage.tsx index 80fcf2e..95c81e2 100644 --- a/Channel-Frontend/src/pages/admin/LegalTemplatesPage.tsx +++ b/Channel-Frontend/src/pages/admin/LegalTemplatesPage.tsx @@ -125,7 +125,7 @@ export const LegalTemplatesPage: React.FC = () => { }; const currentDoc = activeTab === 'NDA' ? ndaDoc : msaDoc; - const fileHost = (import.meta.env.VITE_API_URL || 'http://localhost:5000/api/v1').replace('/api/v1', ''); + const fileHost = (import.meta.env.VITE_API_URL || '/api/v1').replace('/api/v1', ''); // Header component const headerNode = ( diff --git a/Channel-Frontend/src/services/axios.ts b/Channel-Frontend/src/services/axios.ts index dd2d789..3649672 100644 --- a/Channel-Frontend/src/services/axios.ts +++ b/Channel-Frontend/src/services/axios.ts @@ -1,7 +1,7 @@ import axios from 'axios'; export const axiosInstance = axios.create({ - baseURL: import.meta.env.VITE_API_URL || 'http://localhost:5000/api/v1', + baseURL: import.meta.env.VITE_API_URL || '/api/v1', headers: { 'Content-Type': 'application/json', }, diff --git a/Channel-Frontend/vite.config.ts b/Channel-Frontend/vite.config.ts index 0831c47..0dfd9d5 100644 --- a/Channel-Frontend/vite.config.ts +++ b/Channel-Frontend/vite.config.ts @@ -10,6 +10,18 @@ export default defineConfig({ "toughly-coinstantaneous-dimple.ngrok-free.dev", "spruce-fridge-destiny.ngrok-free.dev" ], - cors: true + cors: true, + proxy: { + '/api': { + target: 'http://localhost:5000', + changeOrigin: true, + secure: false, + }, + '/uploads': { + target: 'http://localhost:5000', + changeOrigin: true, + secure: false, + } + } } });