auth0 / auth0.js

Auth0 headless browser sdk
MIT License
987 stars 492 forks source link

Error Using browser-only version of superagent in non-browser environment #878

Closed MaksSlesarenko closed 5 years ago

MaksSlesarenko commented 5 years ago

When upgrading from v9.6.1 to upper versions on the server I get following error:

Using browser-only version of superagent in non-browser environment

Node v8.8 OS: Linux/Mac

luisrudge commented 5 years ago

auth0.js is not meant to be used in a server environment.

GaddMaster commented 4 years ago

How can we only import if on client ?

r3plica commented 3 years ago

With auth0.js ever work in angular universal? I have no need to use it if it can't.

btakita commented 2 years ago

TLDR: Removing auth0-js from the server side & batch processing while having auth0-js on the client side adds unnecessary complexity & rearchitecting to the app just to remove this warning.

Please consider making an isomorphic version of auth0-js. Non-browser shim methods with exceptions could be implemented. package.json > exports > browser may be useful...https://nodejs.org/api/packages.html#conditional-exports

Edit: I located the cause for particular situation. I was importing the version from the auth0-js library. To fix the warning, I updated the import to:

import { version } from 'auth0-js/package.json'

This solution is not necessarily future-proof, but it works for now.


Isomorphic JS component libraries are common. The Hydration strategy of some of these libraries (e.g. SolidJS) require the DOM to be exactly the same for SSR & the initial CSR. Some of these libraries used on both the client & server side are also used for batch processing in a node.js environment. Typescript types are used in some of the logic, including error handling.