【发布时间】:2021-12-23 00:26:48
【问题描述】:
【问题讨论】:
标签: asp.net-core azure-web-app-service asp.net-core-5.0 azure-appservice
【问题讨论】:
标签: asp.net-core azure-web-app-service asp.net-core-5.0 azure-appservice
解决了
我没有在生产 appsettings.json 中包含 CORS 配置中使用的参数(frontendURL)
services.AddCors(options=> {
var frontendURL = Configuration.GetValue<string>("frontend_url");
options.AddDefaultPolicy(builder=> {
builder.WithOrigins(frontendURL).AllowAnyMethod().AllowAnyHeader();
});
});
appsettings.json
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"ConnectionStrings": {
"BoletusConexion": ".....;"
},
"frontend_url": "http://localhost:4200",
"AllowedHosts": "*"
}
【讨论】: