我正在使用ocelot网关。
下面是示例配置
{
"DownstreamPathTemplate": "/ipgeo?apiKey={key}&ip={ip}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "api.ipgeolocation.io",
"Port": 80
}
],
"UpstreamHttpMethod": ["GET"],
"UpstreamPathTemplate": "/GLI/secondary?apiKey={key}&ip={ip}"
}如您所见,有两个查询参数。当我用邮递员发送请求时:
http://localhost:5000/GLI/secondary?apiKey=aaa&ip=8.8.8.8OCELOT获得重复的查询参数并生成一个下游url,如下所示:
http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8控制台屏幕:
info: Ocelot.Requester.Middleware.HttpRequesterMiddleware[0]
requestId: 0HMFNFVDSDQH9:0000000A, previousRequestId: no previous request id, message: 301 (Moved Permanently) status code, request uri: http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8我怎么才能改变这个?
发布于 2022-09-15 13:49:51
同样的问题,
对于我的作品使用这种语法,基本上我已经删除了"?“UpstreamPathTemplate中的符号
"DownstreamPathTemplate": "/GLI/secondary?{everything}"
"UpstreamPathTemplate": "/GLI/secondary{everything}"发布于 2022-07-19 10:17:28
您可以使用
"DownstreamPathTemplate": "/ipgeo?{everything}""UpstreamPathTemplate": "/GLI/secondary?{everything}"或
"UpstreamPathTemplate": "/GLI/secondary/{everything}"https://stackoverflow.com/questions/71250588
复制相似问题