在 Startup 類中的
(1)ConfigureServices 函數中配置:
//配置跨域處理,允許所有來源
services.AddCors(options =>
options.AddPolicy("all", p => p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader())
);
(2) Configure 函數中配置:
app.UseCors("all");
ok ,完美解決