【发布时间】:2017-04-19 22:42:18
【问题描述】:
我在 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'。
这个设置有什么问题?
【问题讨论】:
标签: symfony cors http-headers nelmiocorsbundle