NextJS Sending HTTP-Only Cookie in Requests

58 Views Asked by At

I am working on moving my React App to NextJS. My application has a custom backend API which sends an http-only cookie on authorization. On my original React App without NextJS, my API endpoints' handlers would see the http-only cookie on all subsequent requests made by the frontend. In my NextJS app, I see the http-only cookie being set on authorization and sent on all requests, however; on my API, I am not actually seeing the cookie in the requests made.

My component here is server-side. I am not sure if this is what is causing the problem or if there are some extra steps I need to take to make this work. Any advice here would be greatly appreciated. Happy to provide more information and code if needed.

[...nextauth].ts

import { authOptions } from "@/authOptions";
import NextAuth from "next-auth/next";

export default NextAuth(authOptions)

authOptions.ts

import CredentialsProvider from "next-auth/providers/credentials"
import { authorize } from "@/oauth";

const providers = [
  CredentialsProvider({
    id: 'trainingTracker',
    name: "Training Tracker",
    credentials: {
      username: { label: "Username", type: "text", placeholder: "username" },
      password: { label: "Password", type: "password" },
    },
    authorize: authorize
  })
]


export const authOptions: any = {
  providers: providers,
}

0

There are 0 best solutions below