由于不再维护 ocelot,我决定将 YARP 作为我的 API 网关,但是当我通过它访问我的一个端点时,它给了我这个愚蠢的错误:
"ReverseProxy": {
"Routes": {
"client-route": {
"ClusterId": "client-cluster",
"CorsPolicy": "customPolicy",
"Match": {
"Path": "client-service/{**remainder}"
},
"Transforms": [
{ "X-Forwarded": "Off" },
{
"PathPattern": "/{**remainder}"
}
]
}
},
"Clusters": {
"client-cluster": {
"Destinations": {
"destination1": {
"Address": "https://URLWithSwagger/"
}
}
}
}
}
但是当我将路径从 更改为 时"client-service/{**remainder}"
,"/{**remainder}"
一切正常!关于这个错误的根源有什么建议吗?
更新:这是 program.cs :
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddReverseProxy()//.AddConfigFilter();
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
var app = builder.Build();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapReverseProxy();
app.Run();