Error: URL is malformed "/". Please use only absolute URLs
stitot opened this issue · comments
stitot commented
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
I've implemented the example at https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#app-router
In production (npm run start) I get the following error when navigating to a protected page:
⨯ Error: URL is malformed "/". Please use only absolute URLs - https://nextjs.org/docs/messages/middleware-relative-urls
at validateURL (/Users/stiantotland/Documents/www/kbbno/.next/server/chunks/939.js:11:72693)
at NextResponse.redirect (/Users/stiantotland/Documents/www/kbbno/.next/server/chunks/939.js:11:71285)
... 2 lines matching cause stack trace ...
at async /Users/stiantotland/Documents/www/kbbno/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39523 {
[cause]: TypeError: Invalid URL
at new URL (node:internal/url:775:36)
at validateURL (/Users/stiantotland/Documents/www/kbbno/.next/server/chunks/939.js:11:72658)
at NextResponse.redirect (/Users/stiantotland/Documents/www/kbbno/.next/server/chunks/939.js:11:71285)
at GET (/Users/stiantotland/Documents/www/kbbno/.next/server/app/api/download/[_id]/route.js:1:1620)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/stiantotland/Documents/www/kbbno/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39523 {
code: 'ERR_INVALID_URL',
input: '/'
}
}
This does not happen in dev (npm run dev). I've also tried with absolute returnTo URL, and I'm not using any middleware.
Reproduction
See above
Additional context
No response
nextjs-auth0 version
3.2.0
Next.js version
14.0.1
Node.js version
18