From a54c38b0979ee1f10daff1274467fd4d2832d80e Mon Sep 17 00:00:00 2001 From: Serhii Zautkin Date: Mon, 2 Mar 2026 14:16:32 -0800 Subject: [PATCH] CADC-14486 Path fix1 --- .../src/app/api/auth/[...nextauth]/route.ts | 26 +------------------ .../src/auth/cadc-auth/credentials.ts | 3 +++ 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/rafts/frontend/src/app/api/auth/[...nextauth]/route.ts b/rafts/frontend/src/app/api/auth/[...nextauth]/route.ts index af53c8e5..370ff0cb 100644 --- a/rafts/frontend/src/app/api/auth/[...nextauth]/route.ts +++ b/rafts/frontend/src/app/api/auth/[...nextauth]/route.ts @@ -65,30 +65,6 @@ ************************************************************************ */ -import { NextRequest } from 'next/server' import { GET as AuthGET, POST as AuthPOST } from '@/auth/cadc-auth/credentials' -const basePath = process.env.NEXT_PUBLIC_BASE_PATH || '' - -// Fix the URL path for NextAuth v5 which doesn't handle base paths well -function fixUrl(req: NextRequest): NextRequest { - if (!basePath) return req - - const url = new URL(req.url) - // Remove the base path from the pathname for NextAuth processing - if (url.pathname.startsWith(`${basePath}/api/auth`)) { - url.pathname = url.pathname.replace(basePath, '') - } - - return new NextRequest(url, req) -} - -export async function GET(req: NextRequest) { - const fixedReq = fixUrl(req) - return AuthGET(fixedReq) -} - -export async function POST(req: NextRequest) { - const fixedReq = fixUrl(req) - return AuthPOST(fixedReq) -} +export { AuthGET as GET, AuthPOST as POST } diff --git a/rafts/frontend/src/auth/cadc-auth/credentials.ts b/rafts/frontend/src/auth/cadc-auth/credentials.ts index 6f706b1e..50b458b3 100644 --- a/rafts/frontend/src/auth/cadc-auth/credentials.ts +++ b/rafts/frontend/src/auth/cadc-auth/credentials.ts @@ -72,12 +72,15 @@ import { fetchUserInfo } from './fetchUserInfo' import { fetchUserGroups } from './fetchUserGroups' import { authenticateUser } from '@/auth/cadc-auth/authenticateUser' +const appBasePath = process.env.NEXT_PUBLIC_BASE_PATH || '' + export const { handlers: { GET, POST }, auth, signIn, signOut, } = NextAuth({ + basePath: `${appBasePath}/api/auth`, providers: [ CredentialsProvider({ name: 'CADC Login',