Request Entity Too Large(413) - Uploading File with Formdata with Axios and Custom header
Introduction I was trying to upload images to my backend using rest APIs. I was…
May 04, 2021
Next-auth is a fantastic library for abstracting handling of session information.
In our previous post, we have seen How to Detect user is authenticated or not
In this post, we will see how to use session information in client side vs server side.
What is Client Side?
Client side means, whatever code is executed on the browser.
First Include the import statements,
import { getSession } from 'next-auth/client'
Get session info,
const session = await getSession();
Now you can fetch any information you have saved in session.
session.jwt
session.user
We will run this code in Next.js server side in getServerSideProps
import { getSession } from 'next-auth/client'
export async function getServerSideProps({req}) {
let headers = {}
const session = await getSession({ req });
if (session) {
headers = {Authorization: `Bearer ${session.jwt}`};
}
// Use this session information where you want.
}
Introduction I was trying to upload images to my backend using rest APIs. I was…
Introduction In this post, we will see How to load external images to your next…
Introduction In this post, we will see how we can create a content type. And…
Introduction In this post, we will use in Next.js with strapi. And, we will…
Introduction In this post, we will do following: create a Next.js project…
Introduction In our last post, we have seen a full example of Next.js with…
Introduction In this post we will see following: How to schedule a job on cron…
Introduction There are some cases, where I need another git repository while…
Introduction In this post, we will see how to fetch multiple credentials and…
Introduction I have an automation script, that I want to run on different…
Introduction I had to write a CICD system for one of our project. I had to…
Introduction Java log4j has many ways to initialize and append the desired…