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

feat: add useRequestHeaders hook #1605

Closed
wants to merge 1 commit into from
Closed

Conversation

DustinJSilk
Copy link
Contributor

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests

Description

I've added a new hook to Qwik City to expose request headers during SSR - useRequestHeaders

This hook can be used by applications that rely on external APIs that require authentication tokens. Tokens can be stored as a cookie and then retrieved during SSR in a useResource$ hook and passed on to the API.

Currently, the only way to access headers is in the onGet methods.

Use cases and why

    1. SPAs that use a GraphQL API that want to make use of SSR without adding onGet(/etc) methods will use the useResource$ hook to run queries from both environments but need to forward the access tokens onto the API.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant