Skip to content

SC-190481 bug: proxy-headers CORS pre-flight response#105

Closed
tidbit1 wants to merge 2 commits into
mainfrom
bug/SC-190481/proxy-headers-cors-preflight
Closed

SC-190481 bug: proxy-headers CORS pre-flight response#105
tidbit1 wants to merge 2 commits into
mainfrom
bug/SC-190481/proxy-headers-cors-preflight

Conversation

@tidbit1

@tidbit1 tidbit1 commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

Summary by Sourcery

Fix proxyFetch to omit custom headers for OPTIONS requests and refactor header assembly to handle all methods consistently

Bug Fixes:

  • Exclude X-Proxy-Headers from proxy requests when the HTTP method is OPTIONS to support CORS preflight

Enhancements:

  • Derive the outgoing HTTP method and URL dynamically and centralize the proxy header construction in proxyFetch

@sourcery-ai

sourcery-ai Bot commented Aug 6, 2025

Copy link
Copy Markdown

Reviewer's Guide

Refactors proxyFetch to introduce explicit method detection, separate header construction, and conditional inclusion of original request headers to prevent CORS pre-flight failures for OPTIONS requests.

Flow diagram for conditional header logic in proxyFetch

flowchart TD
    A[Start proxyFetch] --> B{Is input a string?}
    B -- Yes --> C[method = init?.method or 'GET']
    B -- No --> D[method = input.method]
    C --> E{Is method OPTIONS?}
    D --> E
    E -- Yes --> F[Do not set X-Proxy-Headers]
    E -- No --> G[Set X-Proxy-Headers]
    F --> H[Set other proxy headers]
    G --> H
    H --> I[Call fetch with POST and constructed headers]
Loading

File-Level Changes

Change Details Files
Conditional omission of X-Proxy-Headers on OPTIONS requests
  • Check if the HTTP method is OPTIONS before adding X-Proxy-Headers
  • Only stringify and attach init.headers when method is not OPTIONS
src/proxy/helpers.ts
Refactor header construction and method resolution
  • Introduced a local method variable derived from input or init.method
  • Initialized headers object separately with authorization, URL, and method fields
  • Updated fetch call to spread init and use the new headers object
src/proxy/helpers.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions

github-actions Bot commented Aug 6, 2025

Copy link
Copy Markdown

🚀 Storybook is ready! 🚀
You can view the Storybook Build here and the Chromatic Build here.

@tidbit1 tidbit1 closed this Aug 12, 2025
@tidbit1
tidbit1 deleted the bug/SC-190481/proxy-headers-cors-preflight branch August 12, 2025 09:29
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