Open
Description
I have sites where my content is only available for authenticated users. In v2 I needed to write code like this to inject the cookie when fetching content because to my knowledge queryContent()
never really supported passing headers.
const params = `?_params={"first":true,"where":[{"_path":"${myRoute.value}"}],"sort":[{"_file":1,"$numeric":true}]}`
const headers = { ...useRequestHeaders(['cookie']) }
const page = await $fetch('/api/_content/query' + params, {
headers,
method: 'GET',
})
In the new version it seems again it is not possible to pass headers when querying. It would be a really nice feature because content might be available only to certain users and not public.
Support passing headers to
- queryCollectionSearchSections
- queryCollectionItemSurroundings
- queryCollectionNavigation
- queryCollection
I am also not sure how access to authenticated content is handled when this is used: WASM SQLite in Browser, can I just in the middleware allow access to /api/database.json
if the user is authorized?