Ocelot Gateway 重复查询参数
我正在使用 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}"
}
如您所见,有两个查询参数。当我使用 postman: OCELOT 发送请求时,
http://localhost:5000/GLI/secondary?apiKey=aaa&ip=8.8.8.8
会获取重复的查询参数并生成如下下游 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
如何更改此设置?
I am using ocelot gateway.
Here is the example configuration
{
"DownstreamPathTemplate": "/ipgeo?apiKey={key}&ip={ip}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "api.ipgeolocation.io",
"Port": 80
}
],
"UpstreamHttpMethod": ["GET"],
"UpstreamPathTemplate": "/GLI/secondary?apiKey={key}&ip={ip}"
}
As you can see, there are two query params. When I send a request using postman:
http://localhost:5000/GLI/secondary?apiKey=aaa&ip=8.8.8.8
OCELOT get duplicate query params and generate a downstream url like this:
http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8
Console screen:
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
How can I change this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
同样的问题,
对于我的作品使用这种语法,基本上我已经删除了“?”
UpstreamPathTemplate
中的符号:Same problem,
For me works use this syntax, basically I have removed the "?" symbol in the
UpstreamPathTemplate
:您可以使用
或
You can use
OR