-
Notifications
You must be signed in to change notification settings - Fork 11
Fix request headers not fowarded in fetch_upstream
#106
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
Conversation
Introduces put_request_headers to merge connection headers into the request before making upstream fetch calls. Also renames put_headers to put_conn_headers for clarity.
Refactors put_request_headers to correctly merge multiple header values and updates fetch_upstream to pass req_headers directly. This ensures headers are properly combined when forwarding requests upstream.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue where request headers from the client connection were not being forwarded to upstream Electric requests in the fetch_upstream function. The change ensures client headers are properly merged with the request before making upstream calls.
- Adds a new
put_req_headersfunction to merge client connection headers into the request - Renames
put_headerstoput_resp_headersfor better clarity between request and response header handling - Updates the
fetch_upstreamflow to include client headers in upstream requests
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@Jdyn I was about to have a proper look at this -- haven't had much time this week, other priorities interfering. Why did you close? |
|
Oh, I had just figured you would have your own sol. Will re-open but also not entirely sure how elegant this solution is. Happy to make any changes to get it in. I have been using the branch in prod and it fully works for me. |
I wondered what your reasons for closing were - whether the patch didn't work or something. @Jdyn rather than request a bunch of changes plus a test I did end up making my own pr based on this: #107 -- your basic approach seemed valid, I just tweaked to handle compatibility with the elixir client's handling of headers (which on review isn't great tbh). |
|
Thanks for the PR and the issue. Closing in favour of #107 |
Introduces put_request_headers to merge conn headers into the request before making upstream fetch calls. Also renames put_headers to put_conn_headers for clarity.
Closes #105
I found a few ways to approach this
One way I considered was to just override the response headers after we receive the response with the original headers with the CORS plug:
Depends on what behavior you guys consider correct, But I assumed its more correct to merge the client request headers with the original conn request headers before sending the request, since Electric handles the headers logic upstream anyway.
I spent a lot of time trying to get a test setup for this, but couldn't figure out how to test
sync_renderinhttpmode. My tests weren't going to the paths I expected when using thesync_renderin theSandbox. Feel free to modify stuff.