Headers for fetch

I'm trying to use browser's fetch() to access a custom API end point /api/test, but it doesn't include auth headers.

This works (using better fetch from authClient):
const data2 = await authClient.$fetch('../test');
testData.value = data2.data;

This does not (using browser's fetch):
const requestURL = 'http://localhost:3000/api/test';
const data = await fetch(requestURL).then((response) => response.json());
testData.value = data;


So fetch needs something from a session. What do I need to add to headers?

It is a Vue app, using Hono for API.
Solution
Solved. Added { credentials: 'include' } to second parameter to fetch
Was this page helpful?