MERN Authentication Tutorial #14 - Protecting API Routes

preview_player
Показать описание
Hey gang, in this MERN auth tutorial, you'll learn how to protect certain API routes from unauthenticated users.

⭐⭐ Get the full course now (without ads) on the Net Ninja Pro site:

⭐⭐ Get access to all free & PREMIUM courses on Net Ninja Pro:

🐱‍💻 Access the course files on GitHub:

🐱‍💻 MERN Stack Tutorial:

🐱‍💻 React Tutorial:

🔥🔥🔥 Other resources:
Рекомендации по теме
Комментарии
Автор

Fantastic! Shaun you have a Natural Talent to teach, Your time, effort and knowledge is so appreciated I have learn't so much, keep it up Dude.

rayturner
Автор

I love the way the application is structured.

dprotocoll
Автор

I’m enjoying this tutorial a lot. Very nice way of structuring the app. Auth routes and workout routes in different files, only require auth middleware in the file where it’s needed, bang!

ianengelbrecht
Автор

Thank you a lot Shaun for sharing such as this amazing lesson! You've brought a lot of people from fundamentals of web development to here
👏

hwaro_
Автор

Great lesson, have learned a lot, thank you Shaun 😀

maskman
Автор

just wondering where is the "async" keyword.
edit: oops! it is at 12:48

md.asifal-mahmud
Автор

the _id part is a little confusing.. why we don't use the _id directly without the request to the database?

ammar
Автор

For me, the error is about the split function. Everything works fine initially, but as soon as I send the request, the backend server crashes and it points out the split() like it does not recognize the function and cannot read its properties.

SaiBaba-zimy
Автор

I have one question. isn't findOne by id, when we want just id that we already have, important there. minute 9:14, could we skip this await and just pass there _id or some object made with this property

msaters
Автор

Maybe one day you can teach use using react with typescript for authentication too?

AN-qwye
Автор

But how do you ensure that a workout is only visible to the user who made the workout? So the user has to be logged in but also the correct user?

Anteater
Автор

Hi all, so when I'm destructuring the "authorization" property from headers, it looks like there's no such property inside headers, I console.log(authorization) and it returned "undefined", any suggestions? Thank you!

yuzuo
Автор

Hi Shaun, Could you please explain when to use

=> res.status().json() vs => return res.status().json()

Thanks in advance. We love you.

selvaganeshm
Автор

If we are grabbing the _id from the decoded token, why is it necessary to make an extra call to the DB to get the user._id? don't we have it already from the decoded token?

omarzalama
Автор

I want apis to be accessible by owner only so how can I do it'

jaikhatri
Автор

Implementation upto this point is not handling the condition that if there is no record in the database with the user id from the valid token.

nimeshganatra
Автор

I have an error 401 even though I have authContext and logged in, my authorization is undefined :( now I'm stuck

evbwe
Автор

What's the best way about automatically logging the user out if the token expires? I've tried checking against expiration time in requireAuth and AuthContext but nothing seems to do anything? Thanks!

jesseswilson
Автор

Hi can anyone explain how I can do the same in Nextjs, thank you in advance

faruksardar
Автор

Would you consider deploying this express code to Lambda or App Runner at the end?🥲

anandhukraju