Open robcaldecott opened 4 days ago
Hey @robcaldecott 👋
We recently released a fix in 4.0.0-beta.7
that removes the check that enforces this — would you mind upgrading to that latest version and letting me know if that fixes the issue for you?
I'm not sure if this is a bug but I fear it might catch others out so wanted to know the "right" way to handle the base URL and if a lack of scheme is likely to cause us issues elsewhere.
The APP_BASE_URL
environment variable should include the protocol as well, for example: http://localhost:3000
Checklist
Description
When we deploy our app to prod using the v3 client, the base URL does not require the scheme (e.g.
https://
) and all the auth0 supplied middleware works with no issues, including redirects to login for any protected routes.We are now using the v4 beta, which has been excellent so far, but when we deployed to prod we were greeted with a
500
error when our middleware attempts to redirect the user to the auth0 login page.Our middleware looks something like this:
The missing
https://
on the base URL causes thatnew URL
to throw anInvalid URL
error.We are working around this by changing our custom auth0 client to something like this:
And this fixes the issue.
I'm not sure if this is a bug but I fear it might catch others out so wanted to know the "right" way to handle the base URL and if a lack of scheme is likely to cause us issues elsewhere.
Thanks.
Reproduction
See middleware above.
Additional context
No response
nextjs-auth0 version
4.0.0-beta.6
Next.js version
15.0.3
Node.js version
20