Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3/v4 beta: both do not work with Next.js Server Components #862

Closed
5 tasks done
tomsseisums opened this issue May 18, 2023 · 5 comments
Closed
5 tasks done

v3/v4 beta: both do not work with Next.js Server Components #862

tomsseisums opened this issue May 18, 2023 · 5 comments
Labels
bug This points to a verified bug in the code

Comments

@tomsseisums
Copy link

Checklist

  • 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

  • v3 uses superagent-proxy
  • v4 uses node-fetch

Next.js 13.x for /app directory has standards compliant fetch functionality and nothing else works.

Reproduction

Any call to the API will fail with the error below using v4:

- warn ./node_modules/node-fetch/lib/index.js
Module not found: Can't resolve 'encoding' in '/Users/tomsseisums/Projects/Hakio/hakio_cloud/platform/hakio_cloud_frontend/node_modules/node-fetch/lib'

Import trace for requested module:
./node_modules/node-fetch/lib/index.js
./node_modules/auth0/dist/cjs/lib/runtime.js
./node_modules/auth0/dist/cjs/auth/passwordless.js
./node_modules/auth0/dist/cjs/auth/index.js
./node_modules/auth0/dist/cjs/index.js
./src/utils/auth0.server.ts
./src/app/page.tsx

Or with the error below when using v3 (although, this seems like a different issue):

- error ./node_modules/rest-facade/src/Client.js:38:4
Module not found: Can't resolve 'superagent-proxy'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/rest-facade/src/index.js
./node_modules/auth0/src/management/index.js
./node_modules/auth0/src/index.js
./src/utils/auth0.server.ts
./src/app/page.tsx

Additional context

No response

node-auth0 version

[email protected]

Node.js version

v18.16.0

@tomsseisums tomsseisums added the bug This points to a verified bug in the code label May 18, 2023
@tomsseisums
Copy link
Author

Ah, okay noticed readme for superagent-proxy, that solved the error, but this warning is present for all requests v3:

- warn ./node_modules/rest-facade/node_modules/formidable/src/Formidable.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/rest-facade/node_modules/formidable/src/Formidable.js
./node_modules/rest-facade/node_modules/formidable/src/index.js
./node_modules/rest-facade/node_modules/superagent/lib/node/index.js
./node_modules/rest-facade/src/Client.js
./node_modules/rest-facade/src/index.js
./node_modules/auth0/src/Auth0RestClient.js
./node_modules/auth0/src/management/BaseManager.js
./node_modules/auth0/src/management/ClientGrantsManager.js
./node_modules/auth0/src/management/index.js
./node_modules/auth0/src/index.js
./src/utils/auth0.server.ts
./src/app/page.tsx

@adamjmcgrath
Copy link
Contributor

Hi. @tomsseisums - thanks for raising this

Next.js 13.x for /app directory has standards compliant fetch functionality and nothing else works.

For v4 - you can provide your own fetch implementation if you don't want to use node-fetch https://auth0.github.io/node-auth0/beta/interfaces/management.ManagementClientOptionsWithToken.html#fetchApi

It's not possible for us to default to native fetch and still support Node LTS

Ah, okay noticed readme for superagent-proxy, that solved the error, but this warning is present for all requests v3:

This is an issue with Formidable which we are moving off in v4

@tomsseisums
Copy link
Author

Ah, nice! Will test the fetchApi sometime, to see how that works. Funnily, it was super easy to set up the endpoints I needed for Auth0 with just the native fetch.

@naishe
Copy link

naishe commented Jun 26, 2023

For reference: #874 (comment)

@adamjmcgrath
Copy link
Contributor

Hi @tomsseisums - the latest v4 beta uses node-fetch@3 which doesn't have the "Can't resolve 'encoding'" warning on Next.js

More info on the Beta here #859

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

3 participants