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

From Discord: Seeking Feedback on CORS Behavior of FetchHttpClient in Effect Typescript Library #4568

Open
effect-bot opened this issue Mar 9, 2025 · 0 comments

Comments

@effect-bot
Copy link

Summary

In the discussion, corcoder raised an issue about CORS behavior when using FetchHttpClient in the Effect Typescript library, suspecting it might be a bug. sbrg suggested that the problem might be related to tracing, and identified that preflight requests include headers like b3, traceparent, which could trigger CORS restrictions. To work around this issue, sbrg provided a code snippet that disables tracing:

import { withTracerDisabledWhen } from "@effect/platform/HttpClient"

// ...

program.pipe(
  Effect.provide(FetchHttpClient.layer),
  Effect.scoped,
  Effect.provide(DevToolsLive),
  withTracerDisabledWhen(() => true),
  NodeRuntime.runMain
)

corcoder confirmed that this solution resolved their issue and expressed gratitude to sbrg. They also suggested that this information should be added to the documentation to help others who might face similar issues, especially newcomers to the Effect library.

sbrg agreed that an issue should be submitted and mentioned a bot—they referred to it as /issueify—that could potentially automate issue creation on the GitHub repository for Effect.

Key Takeaways:

  1. CORS Issue with FetchHttpClient: The tracing mechanism can cause additional headers to be sent in HTTP requests, potentially causing CORS issues.

  2. Tracing Workaround: Disabling tracing for HTTP requests is a viable workaround to prevent preflight requests from adding headers that trigger CORS restrictions.

  3. Documentation Suggestion: There is a need to address this issue in the documentation to aid users, particularly newcomers.

  4. Community Tools: The community has tools like the /issueify command to help streamline the process of creating GitHub issues from Discord discussions.

Discord thread

https://discord.com/channels/795981131316985866/1348263235148714096

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

No branches or pull requests

1 participant