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

[Bug?]: Headers in Subscription #11732

Open
1 task done
dennemark opened this issue Nov 22, 2024 · 0 comments
Open
1 task done

[Bug?]: Headers in Subscription #11732

dennemark opened this issue Nov 22, 2024 · 0 comments
Labels
bug/needs-info More information is needed for reproduction

Comments

@dennemark
Copy link
Contributor

dennemark commented Nov 22, 2024

What's not working?

Hi,
I am using custom headers in my graph ql client config.

  httpLinkConfig: {
    credentials: 'include',
    headers: {
      'slug': getSlug(),
    },
  },

they reach the backend of graphql when setting context. However not within a subscription. I can see it in my network tab, that the event stream is missing the slug header.
Looking at SSELink, the header infos are not forwarded properly here and in the authorization line below.

return { ...headers }

How do we reproduce the bug?

Use the countdown redwood example, add httpLinkConfig as shown above. Check network tab, if headers of subscription are included.

What's your environment? (If it applies)

System:
    OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 20.11.0 
    Yarn: 4.4.0 
  npmPackages:
    @redwoodjs/auth-custom-setup: 8.4.0 => 8.4.0 
    @redwoodjs/auth-dbauth-setup: 8.4.0 => 8.4.0 
    @redwoodjs/cli-data-migrate: 8.4.0 => 8.4.0 
    @redwoodjs/core: 8.4.0 => 8.4.0 
    @redwoodjs/realtime: 8.4.0 => 8.4.0 
    @redwoodjs/studio: 11.4.0 => 11.4.0

Are you interested in working on this?

I tried a patched version and it seems to work. I could contribute the necessary changes. See the commented spots

 const { credentials, referrer, referrerPolicy, ...rest } = httpLinkConfig?.headers || {}; // here ...rest

    this.client = createClient({
      url,
      headers: async () => {
        const token = await auth.tokenFn();
        if (!token) {
          return { ...headers, ...rest };  // here ...rest
        }
        return {
          Authorization: `Bearer ${token}`,
          "auth-provider": auth.authProviderType,
          ...headers,
          ...rest // here ...rest
        };
      },
  • I'm interested in working on this
@dennemark dennemark added the bug/needs-info More information is needed for reproduction label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction
Projects
None yet
Development

No branches or pull requests

1 participant