Azure CORS: в запрошенном ресурсе отсутствует заголовок «Access-Control-Allow-Origin» - PullRequest
0 голосов
/ 24 апреля 2020

У меня есть вызов POST для Azure контейнера хранения (BLOB), который возвращается к следующей ошибке. У меня также есть конфигурация CORS на месте. Ниже приведен метод. Я использую Angular 5 с. net ядро ​​2.1

  private static void ConfigureCors(ServiceProperties serviceProperties)
        {
            serviceProperties.Cors = new CorsProperties();
            serviceProperties.Cors.CorsRules.Add(new CorsRule()
            {
                AllowedHeaders = new List<string>() { "*" },
                AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post,
                AllowedOrigins = new List<string>() { "*" },
                ExposedHeaders = new List<string>() { "*" },
                MaxAgeInSeconds = 200 
            });
        }

CORS error when calling blob contaiter

1 Ответ

0 голосов
/ 24 апреля 2020

Пожалуйста, добавьте PUT в ваши разрешенные методы как Upload Blob это операция PUT, а не POST.

private static void ConfigureCors(ServiceProperties serviceProperties)
        {
            serviceProperties.Cors = new CorsProperties();
            serviceProperties.Cors.CorsRules.Add(new CorsRule()
            {
                AllowedHeaders = new List<string>() { "*" },
                AllowedMethods = CorsHttpMethods.Put | CorsHttpMethods.Get | CorsHttpMethods.Head | CorsHttpMethods.Post | CorsHttpMethods.Put,
                AllowedOrigins = new List<string>() { "*" },
                ExposedHeaders = new List<string>() { "*" },
                MaxAgeInSeconds = 200 
            });
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...