nelmio / NelmioCorsBundle

Adds CORS (Cross-Origin Resource Sharing) headers support in your Symfony application
https://symfony.com/bundles/NelmioCorsBundle/
MIT License
1.89k stars 108 forks source link

AJAX not allowed for POST and PATCH even though it works for GET, PUT and DELETE #76

Closed khalid-s closed 7 years ago

khalid-s commented 7 years ago

dependencies: "symfony/symfony": "3.2.*", "nelmio/cors-bundle": "^1.5",

For POST and PATCH methods:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test.dev' is therefore not allowed access.

GET, PUT and DELETE are working properly

I am using Angular4 on my front (Just in case...)

khalid-s commented 7 years ago

after an evening on this issue, i noticed that for angular 4, you need to add the content-type in the allowed_headers when performing POST request

allow_headers: ['X-Custom-Auth', 'content-type']