File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -183,8 +183,9 @@ export async function Auth(
183183 if ( error instanceof CredentialsSignin ) params . set ( "code" , error . code )
184184
185185 const pageKind = ( isAuthError && error . kind ) || "error"
186- const pagePath = config . pages ?. [ pageKind ] ?? `/${ pageKind . toLowerCase ( ) } `
187- const url = `${ internalRequest . url . origin } ${ config . basePath } ${ pagePath } ?${ params } `
186+ const pagePath =
187+ config . pages ?. [ pageKind ] ?? `${ config . basePath } /${ pageKind . toLowerCase ( ) } `
188+ const url = `${ internalRequest . url . origin } ${ pagePath } ?${ params } `
188189
189190 if ( isRedirect ) return Response . json ( { url } )
190191 return Response . redirect ( url )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as jose from "jose"
33import * as o from "oauth4webapi"
44
55import GitHub from "../../src/providers/github.js"
6+ import Credentials from "../../src/providers/credentials.js"
67
78import { makeAuthRequest } from "../utils.js"
89
@@ -66,3 +67,21 @@ describe("assert GET callback action", () => {
6667 )
6768 } )
6869} )
70+
71+ it ( "should redirect to the custom error page is custom error page is defined" , async ( ) => {
72+ const { response } = await makeAuthRequest ( {
73+ action : "callback" ,
74+ path : "/credentials" ,
75+ config : {
76+ pages : {
77+ error :'/custom/error'
78+ } ,
79+ providers : [ Credentials ] ,
80+ } ,
81+ } )
82+
83+ expect ( response . status ) . toEqual ( 302 )
84+ expect ( response . headers . get ( "location" ) ) . toEqual (
85+ `https://authjs.test/custom/error?error=Configuration`
86+ )
87+ } )
You can’t perform that action at this time.
0 commit comments