I have a ASP.NET Web API controller which inherits from a custom class which in turn inherits from System.Web.Http.ApiController
. In one of my actions, I return a URL to another action of the same controller by using Url.Link()
.
Recently, we introduced a new version of the application in .NET 8. But we keep the legacy app and forward the requests to it by using a reverse proxy (YARP in our case). During this, we changed the port for the legacy app in local IIS to something like 12345
. The new app is hosted on a Docker container and the routing is done by using Ingress.
This change, however, adds the port number to the host when the request is received by the legacy app. This causes a CORS policy error when the client tries to call the returned URL.
So, I'm trying to figure out where I can fix the host for the returned URL.
What I've already tried
- Adding
proxy_set_header X-Forwarded-Host
to nginx configuration. It didn't seem to make any change. - Setting
HttpContext.Current.Request.ServerVariables["HTTP_HOST"]
inApplication_BeginRequest
inGlobal.asax.cs
(in legacy app). When I debug and step into my action, I can see thatRequest.Headers.Host
is changed accordingly, butRequest.RequestUri
still showing the old host (with port) and so doesUrl.Link()
.
Anything I might have missed? Or any other subtle solution?
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745300284a4621395.html
评论列表(0条)