【问题标题】:Problems publishing ASP.NET Core 5 Web API app in Azure App Service在 Azure 应用服务中发布 ASP.NET Core 5 Web API 应用时出现问题
【发布时间】:2021-12-23 00:26:48
【问题描述】:

我已经发布了我的网络 API

但我得到了这个错误

在诊断工具中我看到了这个,但我不明白

有什么想法吗?

谢谢

【问题讨论】:

    标签: asp.net-core azure-web-app-service asp.net-core-5.0 azure-appservice


    【解决方案1】:

    解决了

    我没有在生产 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": "*"
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-24
      • 1970-01-01
      • 2016-11-08
      • 2023-03-16
      • 1970-01-01
      • 2022-11-21
      • 2018-10-22
      • 1970-01-01
      • 2020-04-12
      相关资源
      最近更新 更多