You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was an original bug reported here in #1062 that with-middleware-auth-required doesn't prepend the basePath. The solution was to append a static returnUrl.
We would like users to be redirected to the page they had tried to access prior to being redirected, which limits our ability to use the static returnTo solution.
This is causing issues for our setup similar to that original issue — our app serves distinct nextjs apps at different paths (e.g. app1 is served from domain.com/app1, and app2 is served from domain.com/app2). This means that redirects from nextjs-auth0 are redirecting users to a different application following successful login.
Expectation
Users should be redirected back to the original URL they were redirected from.
Possible Solution
The NextRequest.nextUrl property provides a basePath variable that seems to be set to the initial route paramer. Appending it to the NextResponse.redirect() url appears to fix this issue.
I couldn't change the behaviour of the method itself in a minor release because it might break users that have worked around this limitation in the past (by customizing the login or callback handlers)
Checklist
Description
There was an original bug reported here in #1062 that with-middleware-auth-required doesn't prepend the basePath. The solution was to append a static returnUrl.
We would like users to be redirected to the page they had tried to access prior to being redirected, which limits our ability to use the static
returnTo
solution.This is causing issues for our setup similar to that original issue — our app serves distinct nextjs apps at different paths (e.g. app1 is served from
domain.com/app1
, and app2 is served fromdomain.com/app2
). This means that redirects fromnextjs-auth0
are redirecting users to a different application following successful login.Expectation
Users should be redirected back to the original URL they were redirected from.
Possible Solution
The
NextRequest.nextUrl
property provides abasePath
variable that seems to be set to the initial route paramer. Appending it to theNextResponse.redirect()
url appears to fix this issue.Are there any known reasons the
NextRequest.nextUrl.basePath
value shouldn't/couldn't be used here?Reproduction
next.config
nav.tsx
,layout.tsx
, and env to include the basepathprofile-middleware
route to be redirected to universal loginAdditional context
nextjs-auth0 version
3.0.0
Next.js version
13.4.10
Node.js version
18.16.0
The text was updated successfully, but these errors were encountered: