Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding headers to query functions in v3 #2831

Open
oripka opened this issue Nov 1, 2024 · 0 comments
Open

Support adding headers to query functions in v3 #2831

oripka opened this issue Nov 1, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@oripka
Copy link

oripka commented Nov 1, 2024

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?

@oripka oripka added the enhancement New feature or request label Nov 1, 2024
@oripka oripka changed the title Support padding headers to query functions Support adding headers to query functions in v3 Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant