Skip to content

withMiddlewareAuthRequired - A Node.js API is used which is not supported in the Edge Runtime. #1152

@TrevorThomp

Description

@TrevorThomp

Checklist

  • The issue can be reproduced in the sample app (or N/A).
  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the examples 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 swapped the usage of withPageAuthRequired and withApiAuthRequired with withMiddlewareAuthRequired and when I run next build I'm seeing the following error that fails to build my containers in GCP.

./node_modules/next/dist/server/web/spec-extension/image-response.js
A Node.js API is used (process.turbopack at line: 47) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
 ./node_modules/next/dist/server/web/spec-extension/image-response.js
./node_modules/next/server.js
./node_modules/@auth0/nextjs-auth0/dist/helpers/with-middleware-auth-required.js
./node_modules/@auth0/nextjs-auth0/dist/edge.js

I wasn't noticing this error previously, but recently it has been consistent in each build. I swapped back to using withPageAuthRequired and withApiAuthRequired and also removed withMiddlewareAuthRequired which resolved the errors.

I used the same example as in the docs without any customization so not sure what could cause this to throw. I'm not using Edge API's in my application and they are all standard Node API's.

import { withMiddlewareAuthRequired } from '@auth0/nextjs-auth0/edge';

export default withMiddlewareAuthRequired();

I haven't been able to find anyone else having this same issue, so I've been at a loss. Any insight on this would be appreciated.

Reproduction

  1. Follow doc usage of using withMiddlewareAuthRequired in the middleware.ts file
  2. Run yarn build

SDK version

2.4

Next.js version

13.3

Node.js version

19

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions