question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] [with-firebase-authentication] getServerSideProps issues

See original GitHub issue

Bug report

Describe the bug

I just cloned the example project with-firebase-authentication and followed the instructions within the README.md to setup. After running the command npm run dev and went to my browser on localhost:3000, I received an error within my terminal.

Error: Error serializing `.user` returned from `getServerSideProps` in "/".
Reason: `undefined` cannot be serialized as JSON. Please use `null` or omit this value all together.

To Reproduce

  1. Go to https://github.com/zeit/next.js/tree/canary/examples/with-firebase-authentication
  2. Followed the setup guide exactly.
  3. Go to localhost:3000 to see the webpage
  4. See error within page and terminal

Expected behavior

Expected to see the the login button within the page.

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: macOS
  • Browser: Chrome
  • Version of Next.js: ^9.3.3
  • Version of Node.js: v10.16.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
timneutkenscommented, Apr 24, 2020

Sure!

1reaction
kohchihaocommented, Apr 24, 2020

I may have found a fix for the problem.

Changing within getServerSideProps

const user = req && req.session ? req.session.decodedToken : null

to

const user = req.session && req.session.decodedToken ? req.session.decodedToken : null

seems to fix the issue for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] [with-firebase-authentication] getServerSideProps issues
I just cloned the example project with-firebase-authentication and followed the instructions within the README.md to setup. After running the ...
Read more >
Authenticated server-side rendering with Next.js and Firebase
It only demonstrates how to make authenticated POST requests to an API, not authenticate users inside getServerSideProps . So below I explain how...
Read more >
error serializing `.csrftoken` returned from `getserversideprops`
I just cloned the example project with-firebase-authentication and followed the instructions within the README.md to setup. After running the command npm run ...
Read more >
getServerSideProps not working in nextjs error in mapping
Your main problem is you're trying to call getServerSideProps in Answerhooks but it's not a page component, so you cannot get data on...
Read more >
The Confusing Core Of NextJS - getServerSideProps - YouTube
I hate NextJS. It's awesome.Seriously tho getServerSideProps is a...rough pattern, and I hope this helps clarify why I think soALL MY ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found