Need to configure a response header with DownstreamHeaderTransform
containing multiple values being separated by commas
#2269
-
Hi All, Currently as per ocelot documentation for headers transformation, it does not support multiple header values using we are looking for a way to allow the same without customization and write our own logic for overriding headers like the below which obviously doesn't work: "DownstreamHeaderTransform": {
"Access-Control-Allow-Origin": "'*.domain1.com, *.domain2.com'",
"Access-Control-Allow-Methods": "'GET, POST, PUT, DELETE'"
} Has someone tried to successfully pass header with multiple values in current ocelot version 23.4.5 using If we need to override default Would look for suggestions from community on how they have handled this scenario. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello, Rahul! Don't use comma in header value and everything will be fine. But if downstream services produce such a values with commas then you must encode value. So, the possible solution has provided in #2249 .
Ocelot doesn't support header which values contain commas
I've explained you above how to develop a custom solution which will support commas in headers. Also, please read #2249
👉 #2249
Yes, we can! Replace the following interface service: Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
thanks for providing possible solution approaches currently, we use metadata for passing header |
Beta Was this translation helpful? Give feedback.
Hello, Rahul!
The problem is in used comma char
,
in header values!Did you read this discussion? 👉
Don't use comma in header value and everything will be fine. But if downstream services produce such a values with commas then you must encode value. So, the possible solution has provided in #2249 .
Other possible solutions:
HeaderFindAndReplaceCreator
class replacing,
with something appropriate for your project.HeaderFindAndReplaceCreator
service and replace it in DI container using theIHeaderFindAndReplaceCreator
interface service 👇Ocelot/src/Ocelot/DependencyInjection/OcelotBuilder.cs
Line 56 in 221a22f