Skip to content
0:00 / 0:00

#next.js#cookies#authentication

Next.js Tutorial - Part 7 | Consume Authenticated APIs with cookies

Bruno Antunes

21K subscribers • 7 videos on Hallway

YouTube

Intermediate. Assumes working knowledge.

43K views6 years ago1 recommendation

Web developmentReactFull-stack frameworks

Bruno Antunes shows how to handle API authentication using cookies in Next.js for both server-side and client-side rendering.

This video shows how to consume Authenticated APIs (both Server-side rendering and client-side rendering). We will check the page authentication status based on the API responses. In this simple example, If the API response status is 401, it means the user is not logged in, so we redirect them to the /login page. In order to call the API from server-side rendering, we are "forwarding" all the cookies we receive from the client to the fetch (API) call. ---- Repository: github.com/bmvantunes/youtube-2020-march-nextjs-part7 ---- Next.js Examples: github.com/zeit/next.js/tree/canary/examples ---- MDN Set-Cookie: developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie ---- React Forms with Formik - Video: youtu.be/kYyaJyTLjpk ---- Follow me on: Twitter: twitter.com/bmvantunes Dev.to: dev.to/bmvantunes Website: brunoantunes.net Github: github.com/bmvantunes LinkedIn: linkedin.com/in/bmvantunes

Why it's here

1 person recommends this

What people say. Recommended as a guide for forwarding cookies during server-side rendering in Next.js applications.

u/bmvantunesin r/node • Recommends

Consume Authenticated APIs on Server-Side Rendering Pages

u/bmvantunesin r/Frontend • Recommends

Consume Authenticated APIs on Server-Side Rendering Pages