nuxt / example-auth0

A simple example that shows how to use Nuxt.js with Auth0.
https://auth0.nuxtjs.org
MIT License
722 stars 159 forks source link

ReferenceError: window is not defined #38

Closed findingorder closed 5 years ago

findingorder commented 5 years ago

When I try to clone and 'npm run dev' this project, it seems to build and launch just fine. But when I navigate to localhost:3000, I get the error "ReferenceError: window is not defined". The offending line of code is server-bundle.js line 3538, "const json = window.localStorage.user;". Call stack is:

server-bundle.js:3538:16 getUserFromLocalStorage server-bundle.js:2341:185 server-bundle.js:1630:15 promisify server-bundle.js:1609:10 middlewareSeries server-bundle.js:1125:72

This question is available on Nuxt community (#c28)
ghost commented 5 years ago

This issue as been imported as question since it does not respect example-auth0 issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/example-auth0/issues/c28.

Syafiqq commented 5 years ago

add mode:spa will fix the problem

nuxt.config.js

module.exports = {
  mode: 'spa',
    ...
}
kemaldotearth commented 5 years ago

That works okay if you don't have any need for meta data for example. Since upgrading to latest on an oldish project, I've had an issue on universal getting it to run. It's a rabbit hole of errors after solving one thing to the next 😅

If anyone has any tips here, would appreciate it.

yeahsmaggy commented 5 years ago

@iamanoctopus I'm having the same issue.