我在构建项目(Angular 8)时遇到上述错误。我们如何修复这个错误?
我在 .Net Core 6 中遇到 Cors 问题。尽管 Cors 可以与之前的版本 3.1 配合使用。我搜索了很多没有用。
完整的错误消息是
Access to XMLHttpRequest at 'https://localhost:7230/api/teachers/subjectsByTeacher?teacherId=5&pageNo=1&pageSize=10&sorting=name%20asc' from origin 'https://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
这是我的program.cs类:
var builder = WebApplication.CreateBuilder(args);
// Configure cors. …Run Code Online (Sandbox Code Playgroud)