The Easiest Way to add Auth to a Next App
HTML-код
- Опубликовано: 5 июл 2024
- Learn how to add auth to your next application using next auth and github login.
Newer next auth video for next 14: • Effortless Auth in Nex...
Code:
www.sammeechward.com/the-easi...
Next & Prisma: • Prisma & Next.js
Next Auth & Prisma: • Next Auth and Prisma
Join this channel to get access to perks:
/ @sammeechward
Chapters:
0:00 Intro
1:31 Setup Next Auth
3:58 Setup Github Login
6:05 Session Provider
7:29 useSession
11:00 unstable_getServerSession
14:08 Restrict Pages
15:50 Nav Bar
17:17 Next Image
19:12 Restrict API
21:03 Summary
🔗Moar Links
My Website: www.sammeechward.com
Instagram: / meech_ward
Twitter: / meech_ward
Github: github.com/orgs/Sam-Meech-Ward - Наука
Best next auth video!
I love this kind of contents! Keep it up idol! Wish you can make content in Angular.js also. Thanks for this lesson, appreciate it.
Thank you. Like this video.
Thank you, me too
Thanks once again for another great video man, You're a great help! Also an update: It's no longer experimental now. unstable_getServerSession is deprecated, getServerSession works perfectly now
Was hoping you included Microsoft Azure AD B2C. Hard to find a walk through on it.
As a premium subscriber I approve of this video
😅
Great video! But I´m getting:
"Server Error
TypeError: Cannot read properties of undefined (reading 'getHeader')"
from the getServserSideProps-function.
I refactored with the new getServerSession like this:
import { getServerSession } from "next-auth";
...
export const getServerSideProps = async (req, res) => {
const session = await getServerSession(req, res, authOptions)
...
but other than that my code is pretty much identical to yours. Any help would be greatly appreciated!
I believe the import should come from next-auth/next, so it should be: import { getServerSession } from "next-auth/next";
@@jamesrobert5332 I got it to work, I think what I did different was to give getServerSideProps context as an argument, and then context.req and context.res on getServerSession
does the API restriction prevent user from making request using HTTPS client like Postman?
If the route is protected using next auth, then other clients will need a valid next auth cookie to use those routes.
ha me as well "copilot do the work for me"
👀
🤨