From aabfacc73597489bce07723ea5198490fc31cfe9 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Thu, 11 Jun 2026 14:10:10 +0530 Subject: [PATCH] fix: route client /api/* through /api/gateway/* proxy\n\nLogin, signup, forgot-password, dashboard, contact, help-center, and all dashboard component fetches were calling bare /api/* paths. The SolidStart server has no /api/auth/*, /api/support/*, or /api/kb/* handlers -- only /api/gateway/[...path] proxies to the Rust gateway. So those calls returned HTML (SPA catch-all), the JSON parse threw silently, and the buttons looked dead. Sign In / Sign Up / Forgot Password all appeared to be no-ops.\n\nThis routes every client-side fetch through the existing gateway proxy, matching the pattern already used by src/lib/api.ts.\n\nAlso fixes hardcoded test121 -> test111 in canonical/og:url tags across index, professionals, help-center, and RoleLandingPage. --- src/components/DashboardLayout.tsx | 2 +- src/components/RoleLandingPage.tsx | 2 +- src/components/admin/DashboardDesignPreview.tsx | 2 +- src/components/dashboard/MyDashboardPage.tsx | 10 +++++----- src/lib/auth.tsx | 2 +- src/lib/help-center.ts | 6 +++--- src/routes/contact.tsx | 2 +- src/routes/dashboard.tsx | 4 ++-- src/routes/forgot-password.tsx | 4 ++-- src/routes/help-center/article/[slug].tsx | 2 +- src/routes/help-center/index.tsx | 2 +- src/routes/index.tsx | 2 +- src/routes/login.tsx | 12 ++++++------ src/routes/professionals/index.tsx | 2 +- src/routes/signup.tsx | 8 ++++---- 15 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/components/DashboardLayout.tsx b/src/components/DashboardLayout.tsx index 72ed834..467eb68 100644 --- a/src/components/DashboardLayout.tsx +++ b/src/components/DashboardLayout.tsx @@ -98,7 +98,7 @@ export default function DashboardLayout(props: ParentProps) { const token = sessionStorage.getItem("nxtgauge_access_token"); if (token) { try { - const res = await fetch("/api/auth/session", { + const res = await fetch("/api/gateway/auth/session", { headers: { Accept: "application/json", Authorization: `Bearer ${token}`, diff --git a/src/components/RoleLandingPage.tsx b/src/components/RoleLandingPage.tsx index b30db78..8596f59 100644 --- a/src/components/RoleLandingPage.tsx +++ b/src/components/RoleLandingPage.tsx @@ -115,7 +115,7 @@ export default function RoleLandingPage(props: Props) { return item; }); - const canonical = createMemo(() => `https://test121.nxtgauge.com${props.pathBase}/${encodeURIComponent(String(props.slug || ''))}`); + const canonical = createMemo(() => `https://test111.nxtgauge.com${props.pathBase}/${encodeURIComponent(String(props.slug || ''))}`); const pageTitle = createMemo(() => (content() ? `${content()!.shortTitle} | Nxtgauge` : 'Role | Nxtgauge')); const pageDescription = createMemo(() => content() ? `${content()!.heroDescription} Most role reviews complete in 24-48 hours.` : 'Role landing page on Nxtgauge.' diff --git a/src/components/admin/DashboardDesignPreview.tsx b/src/components/admin/DashboardDesignPreview.tsx index 0f73dc3..4520121 100644 --- a/src/components/admin/DashboardDesignPreview.tsx +++ b/src/components/admin/DashboardDesignPreview.tsx @@ -1054,7 +1054,7 @@ export default function DashboardDesignPreview(props: { try { const token = getToken(); if (!token) return; - const res = await fetch('/api/me/notifications/unread-count', { + const res = await fetch('/api/gateway/me/notifications/unread-count', { headers: { Authorization: `Bearer ${token}` }, credentials: 'include', }); diff --git a/src/components/dashboard/MyDashboardPage.tsx b/src/components/dashboard/MyDashboardPage.tsx index 3c53d3c..5cc6436 100644 --- a/src/components/dashboard/MyDashboardPage.tsx +++ b/src/components/dashboard/MyDashboardPage.tsx @@ -267,14 +267,14 @@ export default function MyDashboardPage(props: Props) { try { if (roleKey === 'COMPANY') { const [jobsRes, appsRes] = await Promise.all([ - fetch('/api/companies/jobs?page=1&limit=100', { + fetch('/api/gateway/companies/jobs?page=1&limit=100', { credentials: 'include', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${window.sessionStorage.getItem('nxtgauge_access_token') || ''}`, }, }), - fetch('/api/companies/jobs?page=1&limit=1', { + fetch('/api/gateway/companies/jobs?page=1&limit=1', { credentials: 'include', headers: { 'Content-Type': 'application/json', @@ -293,7 +293,7 @@ export default function MyDashboardPage(props: Props) { ); if (!jobsRes.ok && !appsRes.ok) setErr('Some company metrics could not be loaded.'); } else if (roleKey === 'CUSTOMER') { - const res = await fetch('/api/customers/requirements?page=1&limit=100', { + const res = await fetch('/api/gateway/customers/requirements?page=1&limit=100', { credentials: 'include', headers: { 'Content-Type': 'application/json', @@ -311,14 +311,14 @@ export default function MyDashboardPage(props: Props) { if (!res.ok) setErr('Some customer metrics could not be loaded.'); } else if (roleKey === 'JOB_SEEKER') { const [jobsRes, appsRes] = await Promise.all([ - fetch('/api/jobseeker/jobs?page=1&limit=100', { + fetch('/api/gateway/jobseeker/jobs?page=1&limit=100', { credentials: 'include', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${window.sessionStorage.getItem('nxtgauge_access_token') || ''}`, }, }), - fetch('/api/jobseeker/applications?page=1&limit=100', { + fetch('/api/gateway/jobseeker/applications?page=1&limit=100', { credentials: 'include', headers: { 'Content-Type': 'application/json', diff --git a/src/lib/auth.tsx b/src/lib/auth.tsx index f530524..6e8e731 100644 --- a/src/lib/auth.tsx +++ b/src/lib/auth.tsx @@ -82,7 +82,7 @@ async function fetchSession(): Promise { const token = getToken(); if (!token) return null; try { - const res = await fetch("/api/auth/session", { + const res = await fetch("/api/gateway/auth/session", { headers: { Accept: 'application/json', Authorization: `Bearer ${token}`, diff --git a/src/lib/help-center.ts b/src/lib/help-center.ts index 270afa9..ed4491c 100644 --- a/src/lib/help-center.ts +++ b/src/lib/help-center.ts @@ -42,7 +42,7 @@ export async function fetchHelpCenterArticles(input: { // Fallback: when backend search returns sparse/empty data, apply local filtering // so users can still find articles by simple keywords. if (input.q && items.length === 0) { - const allRes = await fetch("/api/kb/articles"); + const allRes = await fetch("/api/gateway/kb/articles"); if (allRes.ok) { const allData = await allRes.json(); const allRaw: any[] = Array.isArray(allData) ? allData : (allData.articles ?? []); @@ -62,7 +62,7 @@ export async function fetchHelpCenterArticles(input: { export async function fetchHelpCenterCategories(): Promise { try { - const res = await fetch("/api/kb/categories"); + const res = await fetch("/api/gateway/kb/categories"); if (!res.ok) return HELP_CENTER_SEED_CATEGORIES; const data = await res.json(); const raw: any[] = Array.isArray(data) ? data : (data.categories ?? []); @@ -98,7 +98,7 @@ export async function fetchRelatedArticles(input: { limit?: number; }): Promise { try { - const res = await fetch("/api/kb/articles"); + const res = await fetch("/api/gateway/kb/articles"); if (!res.ok) return pickRelated( HELP_CENTER_SEED_ARTICLES as HelpArticle[], diff --git a/src/routes/contact.tsx b/src/routes/contact.tsx index 8c1f902..b97c9d1 100644 --- a/src/routes/contact.tsx +++ b/src/routes/contact.tsx @@ -158,7 +158,7 @@ export default function ContactPage() { "Job Seeker (Apply jobs)": "GENERAL", }; const category = userTypeToCategory[values().userType] || "GENERAL"; - const res = await fetch("/api/support/tickets", { + const res = await fetch("/api/gateway/support/tickets", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", diff --git a/src/routes/dashboard.tsx b/src/routes/dashboard.tsx index 2a2ec47..38cc1b3 100644 --- a/src/routes/dashboard.tsx +++ b/src/routes/dashboard.tsx @@ -648,7 +648,7 @@ export default function RuntimeDashboardPage() { const email = authEmail || getEmailFromStorage(); if (!email) return; - const checkRes = await fetch("/api/auth/check-email", { + const checkRes = await fetch("/api/gateway/auth/check-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -671,7 +671,7 @@ export default function RuntimeDashboardPage() { const token = getToken(); if (token) { - const switchRes = await fetch("/api/auth/switch-role", { + const switchRes = await fetch("/api/gateway/auth/switch-role", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/src/routes/forgot-password.tsx b/src/routes/forgot-password.tsx index f2f1b83..4d21e6a 100644 --- a/src/routes/forgot-password.tsx +++ b/src/routes/forgot-password.tsx @@ -48,7 +48,7 @@ export default function ForgotPasswordRoute() { } setSubmitting(true); try { - const res = await fetch('/api/auth/forgot-password', { + const res = await fetch('/api/gateway/auth/forgot-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ email: email().trim().toLowerCase() }), @@ -82,7 +82,7 @@ export default function ForgotPasswordRoute() { } setSubmitting(true); try { - const res = await fetch('/api/auth/reset-password', { + const res = await fetch('/api/gateway/auth/reset-password', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ diff --git a/src/routes/help-center/article/[slug].tsx b/src/routes/help-center/article/[slug].tsx index 8115df5..a9f48d5 100644 --- a/src/routes/help-center/article/[slug].tsx +++ b/src/routes/help-center/article/[slug].tsx @@ -26,7 +26,7 @@ export default function HelpCenterArticlePage() { (item) => (item ? fetchRelatedArticles({ article: item, limit: 4 }) : []) ); const canonical = createMemo( - () => `https://test121.nxtgauge.com/help-center/article/${encodeURIComponent(slug())}` + () => `https://test111.nxtgauge.com/help-center/article/${encodeURIComponent(slug())}` ); const pageTitle = createMemo(() => { const a = article(); diff --git a/src/routes/help-center/index.tsx b/src/routes/help-center/index.tsx index db3693f..0f42849 100644 --- a/src/routes/help-center/index.tsx +++ b/src/routes/help-center/index.tsx @@ -10,7 +10,7 @@ export default function HelpCenterPage() { const title = "Help Center | Nxtgauge"; const description = "Browse Nxtgauge guides for getting started, roles, requests, approvals, and platform troubleshooting."; - const canonical = "https://test121.nxtgauge.com/help-center"; + const canonical = "https://test111.nxtgauge.com/help-center"; const [query, setQuery] = createSignal(""); const [category, setCategory] = createSignal(""); diff --git a/src/routes/index.tsx b/src/routes/index.tsx index aff8e86..2882269 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -4,7 +4,7 @@ import PublicLanding from '~/components/PublicLanding'; export default function Home() { const title = 'Nxtgauge | Verified Jobs & Professional Services Platform'; const description = 'Trusted hiring and opportunity discovery for customers, companies, professionals, and job seekers with verification built in.'; - const canonical = 'https://test121.nxtgauge.com/'; + const canonical = 'https://test111.nxtgauge.com/'; return ( <> diff --git a/src/routes/login.tsx b/src/routes/login.tsx index db46f9f..27fb22a 100644 --- a/src/routes/login.tsx +++ b/src/routes/login.tsx @@ -133,7 +133,7 @@ export default function LoginRoute() { } setCheckingRole(true); try { - const response = await fetch("/api/auth/check-email", { + const response = await fetch("/api/gateway/auth/check-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -243,7 +243,7 @@ export default function LoginRoute() { } setSubmitting(true); try { - const res = await fetch("/api/auth/login", { + const res = await fetch("/api/gateway/auth/login", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -283,7 +283,7 @@ export default function LoginRoute() { if (discoveredRoleKeys.length === 0 || isJobSeekerRole(discoveredActiveRole)) { try { - const checkRes = await fetch("/api/auth/check-email", { + const checkRes = await fetch("/api/gateway/auth/check-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -324,7 +324,7 @@ export default function LoginRoute() { let desiredRoleKey = discoveredActiveRole; if (finalAccessToken && requestedRoleKey && requestedRoleKey !== discoveredActiveRole) { try { - const switchRes = await fetch("/api/auth/switch-role", { + const switchRes = await fetch("/api/gateway/auth/switch-role", { method: "POST", headers: { "Content-Type": "application/json", @@ -385,7 +385,7 @@ export default function LoginRoute() { setError(""); setSubmitting(true); try { - const res = await fetch("/api/auth/resend-otp", { + const res = await fetch("/api/gateway/auth/resend-otp", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -409,7 +409,7 @@ export default function LoginRoute() { } setSubmitting(true); try { - const verifyRes = await fetch("/api/auth/verify-email", { + const verifyRes = await fetch("/api/gateway/auth/verify-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", diff --git a/src/routes/professionals/index.tsx b/src/routes/professionals/index.tsx index 2432551..2f535ee 100644 --- a/src/routes/professionals/index.tsx +++ b/src/routes/professionals/index.tsx @@ -17,7 +17,7 @@ const chipNodes = [ export default function ProfessionalsIndexPage() { const [scrollY, setScrollY] = createSignal(0); const [reduceMotion, setReduceMotion] = createSignal(false); - const canonical = 'https://test121.nxtgauge.com/professionals'; + const canonical = 'https://test111.nxtgauge.com/professionals'; const title = 'Professionals | Nxtgauge Verified Service Categories'; const description = 'Explore verified professional categories on Nxtgauge and register with a trust-first workflow built for better opportunity quality.'; diff --git a/src/routes/signup.tsx b/src/routes/signup.tsx index 05f01c5..98c2137 100644 --- a/src/routes/signup.tsx +++ b/src/routes/signup.tsx @@ -133,7 +133,7 @@ export default function SignupRoute() { } try { - const response = await fetch("/api/auth/check-email", { + const response = await fetch("/api/gateway/auth/check-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -218,7 +218,7 @@ export default function SignupRoute() { setSubmitting(true); try { console.log('[register] after canSubmit guard, calling API...'); - const res = await fetch("/api/auth/register", { + const res = await fetch("/api/gateway/auth/register", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -311,7 +311,7 @@ export default function SignupRoute() { } setSubmitting(true); try { - const verifyRes = await fetch("/api/auth/verify-email", { + const verifyRes = await fetch("/api/gateway/auth/verify-email", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include", @@ -376,7 +376,7 @@ export default function SignupRoute() { setServerError(""); setSubmitting(true); try { - const res = await fetch("/api/auth/resend-otp", { + const res = await fetch("/api/gateway/auth/resend-otp", { method: "POST", headers: { "Content-Type": "application/json", Accept: "application/json" }, credentials: "include",