我在Heroku中部署了一个.NET6最小API,该API返回以下CORS错误:从来源'...'存取'...'上的XMLHttpRequest已被CORS原则封锁:请求的资源上不存在“Access-Control-Allow-Origin”标头。但当我在本地运行应用程序时,相同的配置没有返回任何错误。第一个
4sup72z81#
您可能必须启用具有端点路由的Cors。请参阅此文档:https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0#enable-cors-with-endpoint-routing检查您的中间件订单:https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0#middleware-order
1条答案
按热度按时间4sup72z81#
您可能必须启用具有端点路由的Cors。请参阅此文档:https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-6.0#enable-cors-with-endpoint-routing
检查您的中间件订单:https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0#middleware-order