How do you make fetch call from Nextjs to Hono with auth ?

I am not sure if this is the right way to fetch with auth , did not find any docs related to this , normal fetch call i did not how to pass the auth. With this i am getting data:unknown and a 401 error.
No description
Solution:
When you have an entirely seperate Nextjs frontend and Hono backend , to make an authenticated request ```ts const res = await fetch("http://localhost:5000/api/profile", { credentials: "include",...
Jump to solution
4 Replies
Solution
aswnss
aswnss2w ago
When you have an entirely seperate Nextjs frontend and Hono backend , to make an authenticated request
const res = await fetch("http://localhost:5000/api/profile", {
credentials: "include",
headers: header
});
const res = await fetch("http://localhost:5000/api/profile", {
credentials: "include",
headers: header
});
Also you should not use the nextCookies() plugin from auth.ts config file for some reason
aswnss
aswnssOP2w ago
This is when you have a seperate Nextjs frontend and standalone hono server. I dont think for those you replace or route all the api request from Nextjs through hono will face this issue
sebastian
sebastian2w ago
The reason to not use the plugin is beacuse you have separated instance which is not nextjs. its a separate concern. The cookies will be automatically parsed if you have done the integrations in the docs correctly.
aswnss
aswnssOP2w ago
@sebastian you are right , this is my setup , that is why the plugin is not useful to this kind of setup.
No description
No description

Did you find this page helpful?