auth0 / nextjs-auth0

Next.js SDK for signing in with Auth0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: URL is malformed "/". Please use only absolute URLs

stitot opened this issue · comments

Checklist

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