How to add Origin header into swashbuckle Curl request?

In my web api backend application, we are performing authorization token origin validation. This is done by reading Origin header parameter in API request and matching that with the Origin url embedded in Authorization token. This works fine with our Angular client application.

To allow swashbuckle/swagger to pass Authorization token, I added a Authorization parameter using IOperationFilter as explained in, it works great.

Since we perform Request Origin header validation, Curl requests from swagger doesn't work now. I initially thought I can add another Header parameter using IOPeratinFilter called Origin and pass origin url along with API request and implemented the same but when request reaches back-end request does not contain an Origin header.

I can see following CUrl request command is generated from swagger and it has Origin header as expected

curl -X GET --header 'Accept: text/html' --header 'Authorization: bearer <token>' --header 'Origin: http://localhost:6161' 'http://localhost:6161/CustomerPersonalProfiles'

When I tracked this request using Fiddler, I could not see origin header is passed along with the request. enter image description here

How do I configure swashbuckle/swagger configure in such a way that it pass Origin header always with a curl request?

Appreciate your help


comments powered by Disqus