-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handleCallback post-processing #1613
Comments
@jamesarosen, maybe the below is of help.
|
I'm using the App Router and thus type AfterCallbackAppRoute = (
req: NextRequest,
session: Session,
state?: { [key: string]: any }
) => Promise<Session | Response | undefined> | Session | Response | undefined; In that callback, I want to call async function afterCallback(req: NextRequest, session: Session, state?: { [key: string]: any }) {
const { accessToken } = await auth0.getAccessToken(req, res);
await fetch('https://api.example.com', { headers: { authentication: `Bearer ${accessToken}` } });
} But now I'm stuck with an extra |
@jamesarosen did you find a way to successfully use the |
Not yet |
Checklist
Describe the problem you'd like to have solved
I'm trying to do some post-processing in the
callback
handler:Option 1: Throw an Error
The problem with this is that
@auth0/nextjs-auth0
overrides mystatus
with400
and its own error message. The UI is quite poor.Option 2: Modify res
This doesn't do anything because the original handler succeeded, so the modifications to the response are discarded.
Describe the ideal solution
I'd like to be able to replace the Response with one of my own even if the callback succeeded. Ideally, I'd like to be able to render my application's error page.
Alternatives and current workarounds
No response
Additional context
The handleCallback docs have some information on customizing the callback, but not on modifying the response or much on error handling.
This issue suggests using
res.redirect
, but that doesn't work here becausehandleCallback
already finalizedres
.The text was updated successfully, but these errors were encountered: