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.

Update suggested ways of securing pages and API routes

See original GitHub issue

In https://github.com/vercel/next.js/issues/34316#issuecomment-1039037314 I concluded that getInitialProps really does not play well with our auth model. There are simply much better solutions for this now.

We should discourage the usage of it entirely.

https://next-auth.js.org/tutorials/securing-pages-and-api-routes should be updated to also mention Middleware support and finally decide how and where we should document getServerSession (#1535)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
urtheamancommented, Apr 27, 2022

@urtheaman we’re always open for suggestions - what were you thinking specifically?

now it’s well structured. previously i had to switch b/w tutorials and docs.

2reactions
balazsorban44commented, Feb 17, 2022

I’m not really sure actually. I want the Client page to go away mostly, or document how a framework-specific client should be implemented (similar to how we have the REST API docs).

getServerSession is Next.js specific, so I might put it under https://next-auth.js.org/configuration/nextjs probably.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Securing pages and API routes - NextAuth.js
Securing pages and API routes. You can easily protect client and server side rendered pages and API routes with NextAuth.js.
Read more >
Best practices for REST API security: Authentication and ...
If you have a REST API accessible on the internet, you're going to need to secure it. Here's the best practices on how...
Read more >
API Routes: Introduction - Next.js
API routes provide a solution to build your API with Next.js. Any file inside the folder pages/api is mapped to /api/* and will...
Read more >
How To Protect Your API Key In Production With Next.js API ...
The reason why we're writing the API call at the server-side is for securing our API key, and Next.js already makes it an...
Read more >
API security best practices | Google Maps Platform
While it is possible to secure API keys after they're created and in use, there can be different constraints based on how the...
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