我在 Symfony3 下使用 NelmioCorsBundle,设置如下:
nelmio_cors:
defaults:
allow_credentials: false
allow_origin: []
allow_headers: []
allow_methods: []
expose_headers: []
max_age: 0
#hosts: []
origin_regex: false
paths:
'^/api/':
origin_regex: true
allow_origin: ['*']
allow_headers: ['X-Custom-Auth','Content-Type','X-Requested-With','Accept','Origin','Access-Control-Request-Method','Access-Control-Request-Headers','Authorization']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
expose_headers: []
max_age: 3600
'^/':
origin_regex: true
allow_origin: ['*']
allow_headers: ['X-Custom-Auth']
allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
max_age: 3600
hosts: ['^api\.']
这工作正常GET
但是当我尝试使用时POST
我得到
请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问 Origin 'http://localhost:8080'。
这个设置有什么问题?