Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
In one of our previous projects, we decided to use Strapi to gain time in development. It's a great Headless CMS built with NodeJS and ReactJS providing either a Rest and a GraphQL API. We used NextJS for the front application and we choose to use the default authentication method provided by Strapi. Firstly, we found an article on the Strapi blog explaining exactly our case and we were super happy about that. But when decided to start the implemented we discovered that the security of it was not so perfect because they use a plain cookie to keep to the token. After some research, we tried to use a library called next-auth with the Credentials provider included by default. The authentication was working but the front application was not able to receive the Strapi JWT Token required to perform the request on the rest API. We found that next-auth was more oriented for applications using OAuth authentication than a basic email and password system. Because of this we moved to next-iron-session. And after some magic, everything was working like a charm. In this article, we gonna see how you can achieve the same thing in less than 20 minutes.
In one of our previous projects, we decided to use Strapi to gain time in development. It's a great Headless CMS built with NodeJS and ReactJS providing either a Rest and a GraphQL API. We used NextJS for the front application and we choose to use the default authentication method provided by Strapi. Firstly, we found an article on the Strapi blog explaining exactly our case and we were super happy about that. But when decided to start the implemented we discovered that the security of it was not so perfect because they use a plain cookie to keep to the token. After some research, we tried to use a library called next-auth with the Credentials provider included by default. The authentication was working but the front application was not able to receive the Strapi JWT Token required to perform the request on the rest API. We found that next-auth was more oriented for applications using OAuth authentication than a basic email and password system. Because of this we moved to next-iron-session. And after some magic, everything was working like a charm. In this article, we gonna see how you can achieve the same thing in less than 20 minutes.
Related posts
- Should I use next-auth.js for a typical username-password login?
- Streamlining Role-Based Access Control in Next.js with Descope and Auth.js: A Step-by-Step Guide
- Nextauth.js: Use <SessionProvider /> in Next.js "app" directory
- NextAuth with AWS Cognito Email & Google Sign in
- Setting up Next.js with NextAuth, Prisma and "Credentials" Auth Provider