在API的Startup.cs文件中的Configure方法中添加以下代码:
app.Use(async (context, next) => { if (string.IsNullOrWhiteSpace(context.Request.Scheme)) { context.Request.Scheme = "https"; } await next(); });
这会确保在API请求连接到IdentityServer4时,context.Request.Scheme被正确设置为'https”。