I have an API route that requires a session cookie to test Authentication
/api/structure/[module]
When I try to connect this route with axios like:
const res = await axios.get(
`http://localhost:3000/api/structure/${params.name}`,
{ withCredentials: true }
);
it doesn't work.
I am using next-auth so here's the code to get the session:
import {getSession} from 'next-auth/client';
export default async function handler(req, res) {
const session = await getSession({ req: req });
}
but it returns null for the session.
> The weird part is I can consume the route with the browser and it works just fine.
I think it has something to do with the httpOnly cookie or the CURL.
Yes I set withCredentials to true
And my cookie is httpOnly
I spent a week searching for a solution but I didn't manage to find any. Any help Please.