nelmio/NelmioCorsBundle

CORS problem if 'Content-type': 'multipart/form-data'

fabianoroberto opened this issue · 1 comments

Hi,

I have a problem with a POST api only when 'Content-type' is 'multipart/form-data'.
If I remove the image in that request, the api is successfully executed.

This is my config:

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

Error:

CORS header 'Access-Control-Allow-Origin' missing
(No error appear during preflight request (OPTIONS))

I solved my problem by adding 'Accept' in allow_headers:

['Accept', 'Authorization', 'Content-Type']