Access to XMLHttpRequest at 'https://my_api_domain/api/resource/custom-update' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

问题描述 投票:1回答:1
我了解它告诉我,我需要在响应标题中设置'Access-Control-Allow-Origin'。但是据我了解,NelmioCorsBundle应该自动将其注入。

bundle在bundle.php中被删除了

return [ ... Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], ... ];

这是我对NelmioCorsBundle的设置

nelmio_cors: defaults: origin_regex: true allow_origin: ['*'] allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] allow_headers: ['Content-Type', 'Authorization'] expose_headers: ['Link'] max_age: 3600 paths: '^/': ~

我已经阅读了CORS的文档。 

我不希望黑客能够使其在Chrome或Firefox上运行。

我已尝试在响应中手动注入'Access-Control-Allow-Origin:*'
    没有任何作用。
  • 我想念什么?
  • 我使用NelmioCorsBundle在Symfony 4中有一个API。我有一个要求相同API的Vue.js应用程序。我使用谷歌浏览器作为浏览器。当我发送GET请求时,没有问题,但是当我...
  • symfony cors nelmiocorsbundle
    1个回答
    0
    投票
    nelmio_cors: defaults: origin_regex: true allow_origin: ['*'] allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] allow_headers: ['Content-Type', 'Authorization'] expose_headers: ['Link'] forced_allow_origin_value: ['*'] max_age: 3600 paths: '^/': ~
    © www.soinside.com 2019 - 2024. All rights reserved.