Skip to content

feat: Add custom header manager see #663 - #1298

Closed
fstof wants to merge 4 commits into
serverpod:mainfrom
fstof:main
Closed

fstof wants to merge 4 commits into
serverpod:mainfrom
fstof:main

Conversation

@fstof

@fstof fstof commented Aug 21, 2023 •

Copy link
Copy Markdown

This adds the feature to the client where we can add custom headers to all http requests.
This will help in the case where the server is deployed behind a reverse proxy that checks some headers (eg. Authorization)

Added HeaderManager to handle the addition of custom headers to all requests

This has been discussed here #663

Pre-launch Checklist

  • I read the Contribute page and followed the process outlined there for submitting PRs.
  • This update contains only one single feature or bug fix and nothing else. (If you are submitting multiple fixes, please make multiple PRs.)
  • I read and followed the Dart Style Guide and formatted the code with dart format.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///), and made sure that the documentation follows the same style as other Serverpod documentation. I checked spelling and grammar.
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.
  • Any breaking changes are documented below.

If you need help, consider asking for advice on the discussion board.

Breaking changes

None

@github-actions

github-actions Bot commented Aug 21, 2023 •

Copy link
Copy Markdown

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@fstof

fstof commented Aug 21, 2023

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@fstof

fstof commented Aug 23, 2023

Copy link
Copy Markdown
Author

Hi @vlidholt
So this seems to work well, however there is one problem. And I have one question.

The question

Is this an acceptable solution? (Adding a HeaderManager to the Client constructor similar to the authenticationKeyManager)

Then the problem.

Upon testing this... It works well with serverpod_client_io.dart (on android test) but serverpod_client_browser.dart does not work as expected.

When the browser sends the request it actually overrides the Access-Control-Request-Headers header and then "pre flight check" fails.

Not sure what I'm missing...
In my test I added the headers object like this

{
  'my-header1': 'my-value1',
  'my-header2': 'my-value2',
}

But the the keys here are then set as values on the Access-Control-Request-Headers header as can be seen on the screenshot

image

@Isakdl
Isakdl marked this pull request as ready for review September 8, 2023 13:08
@vlidholt

Copy link
Copy Markdown
Collaborator

Thanks a lot for this contribution!

I'm closing this as the functionality is incorporated in this PR, please let me know if it still doesn't help with your use case:
#1435

@vlidholt vlidholt closed this Oct 20, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants