UseProxyToSpaDevelopmentServer slow when passing 'Connection' header #16797
Labels
area-mvc
Includes: MVC, Actions and Controllers, Localization, CORS, most templates
bug
This issue describes a behavior which is not expected - a bug.
Done
This issue has been fixed
help wanted
Up for grabs. We would accept a PR to help resolve this issue
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When using
UseProxyToSpaDevelopmentServer
I noticed that all requests to the proxy were taking over 1 second to complete. When I access the resource directly (not via the SPA proxy) it takes about 2ms. After some debugging, I found that the cause is theConnection
header being passed to the proxied server. When I remove theConnection
header, the request now takes about 40ms.https://github.com/aspnet/AspNetCore/blob/master/src/Middleware/SpaServices.Extensions/src/Proxying/SpaProxy.cs#L133
To Reproduce
Steps to reproduce the behavior:
UseProxyToSpaDevelopmentServer
Expected behavior
The request should respond with similar times as the dev server. I can understand some overhead since it is copying the request and response, but not 500x slower.
Additional notes
I'm not sure if I should make a separate bug for this, but I also ran into an issue with the cookie header getting copied which causes requests to fail. I had to add a pretty hacky solution to our project that removes the cookie header before calling the proxy middleware. I believe the cause of the error is specifically when there is a
SameSite=strict
cookie since it happens when i have a CSRF cookie.Perhaps one mitigation could be to add the ability to disable copying headers or add an allowed/disallowed headers as an option on
UseProxyToSpaDevelopmentServer
.The text was updated successfully, but these errors were encountered: