upd:把OAuthClientId和secret的获取移动到了循环的外面

This commit is contained in:
2025-10-28 08:39:41 +08:00
parent d340be4e2c
commit 8d9e7658d7

View File

@ -27,6 +27,8 @@ namespace KonSoft.InternalGateway.Extensions
.ToList();
var gatewayUrl = configuration["GatewayUrl"];
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
foreach (var clusterGroup in groupedClusters)
{
var routeConfig = yarpConfig.Routes.FirstOrDefault(q =>
@ -39,8 +41,6 @@ namespace KonSoft.InternalGateway.Extensions
// options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API");
options.SwaggerEndpoint(new Uri(new Uri(!string.IsNullOrWhiteSpace(gatewayUrl)? gatewayUrl: clusterGroup.Value.Address), $"{routeConfig.RouteId.Split("-")[0]}/swagger/v1/swagger.json").AbsoluteUri, $"{routeConfig.RouteId} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
}
});