I was creating my own jwt, but I started using next-auth, so it generated one automatically and I stopped creating my own, as there was no need.
The problem is that this generated token does not work to pass as authorization for a post. What could I do?
this is the code for creating a context in the database, in the headers, I am passing a Bearer ${token}, which has the information of a jwt automatically generated by next-auth, but as said, it does not work.
const token = Cookie.get('next-auth.session-token')
async function createContent(event: FormEvent<HTMLFormElement>) {
event.preventDefault()
try {
const formData = new FormData(event.currentTarget)
const contentBody = await api.post('/content', {
content: formData.get('content'),
}, {
headers: {
Authorization: `Bearer ${token}`
}
})
setClicked(true);
setId(contentBody.data.contentCreated.id)
} catch (error) {
console.error("Erro ao criar conteúdo:", error);
}
}