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',