-
Notifications
You must be signed in to change notification settings - Fork 804
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
Adding custom headers, but not seeing them in Fiddler #1477
Comments
Can you please share the code you are using? |
I’ve updated the original post. I forgot to remove the comment characters around the code…
|
Fiddler only shows you the requests from the client to the proxy by default, it doesn't intercept requests from the proxy to the destination without additional config. Can you share your appsettings.json file as well, it's hard to tell which parts of this flow belong to the proxy. What are you expecting this to do? |
Sure.
Here’s the relevant part of the appsettings.
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"reportServerRoute": {
"ClusterId": "reportServerCluster",
"CorsPolicy": "openPolicy",
"Match": {
"Path": "{**catch-all}"
},
}
},
"Clusters": {
"reportServerCluster": {
"Destinations": {
"reportServerDest": {
"Address": http://modsreporting-dev.mdsol.com/
}
}
}
}
I used pathprefix of “/” because the documentation for the config version implied a pathprefix was required, and I want all the routes that come into the proxy server to have these headers added. I initially tried without the pathprefix in the code version, but the results are always the same.
If you look at my screenshot, it certainly looks to me like fiddler is capturing the request from the proxy server to the final destination.
|
Match:Path is required in the route config, AddPathPrefix does something else and is not required, remove it. It looks like you're being redirected (302) from localhost to |
I’m running my proxy server at localhost:44344. The proxy is supposed to forward to https://modsreporting-dev.mdsol.com.
I’m not quite sure what you mean by “host header doesn’t match”…
|
Maybe I’m trying to set this up incorrectly.
I’m doing some development of a new React app that is a report viewing “portal” for a PowerBI Report server.
My actual report server is found at “https://modsreporting-dev.mdsol.com”.
My app is a react app that is running at “http://localhost:3000” (Standard for a react app)
My YARP proxy server is running at “https://localhost:44344”.
I have another web api project running at “https://localhost:44300”, but I don’t need to proxy anything going to that address.
I want ALL traffic that is sent to “https://localhost:44344” to be forwarded to “https://modsreporting-dev.mdsol.com” along with the custom headers I’m trying to add.
Have I messed up something in my “ReverseProxy” section of the appsetttings.json?
|
Your appsettings.json looks fine then. Check the logs from YARP to see what it says about those requests. |
@sarchibald-mdsol - following up after the US holidays - did you resolve your issue? |
Triage: No response for 2+ weeks, closing. Feel free to reopen if there is more info available. Thanks! |
@Tratcher Would you please point me to some documentation on what that additional config is? |
Fiddler injects itself as an outbound client proxy. YARP disables outbound client proxy support on HttpClient by default for performance reasons, it expects to be able to directly access destinations. You'd have to turn that back on. https://microsoft.github.io/reverse-proxy/articles/http-client-config.html#configuring-the-http-client |
@Tratcher, thanks. That got pointed in the right direction. For anyone else looking to enable Fiddler debugging with YARP, I had to add the following when configuring services: services
.AddReverseProxy()
.ConfigureHttpClient((context, handler) =>
{
handler.UseProxy = true;
handler.Proxy = WebRequest.DefaultWebProxy;
}); |
Describe the bug
I'm trying to add some headers to all my routes using the code below. But when I look at my requests in Fiddler, I don't see any of my headers added to the final request.
To Reproduce
Here is the current code:
Got Exceptions? Include both the message and the stack trace
Further technical details
YARP 1.0.0
.NET5
React front end
Windows
Here's a snapshot of what's in Fiddler after executing a request:
The text was updated successfully, but these errors were encountered: