Bonjour,

J'utilise le plugin NelmioCorsBundle. Tous les appels fonctionnent correctement. Lors d'un POST je récupère les données, et ensuite je génère de façon automatique un PDF via Html2Pdf.

Lorsque j'appelle directement l'url de l'API, via postman par exemple, le PDF se génère bien. Lorsque je le fait via le site, l'appel POST me renvoie un code 200, mais ensuite me renvoie une erreur 'Access-Control-Allow-Origin'

Ma config Nelmio :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
nelmio_cors:
    defaults:
        allow_credentials: false
        allow_origin: []
        allow_headers: []
        allow_methods: []
        expose_headers: []
        max_age: 0
        hosts: []
        origin_regex: false
    paths:
        '^/api/':
            allow_origin: ['*']
            allow_headers: ['X-Custom-Auth']
            allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
            max_age: 3600
        '^/':
            origin_regex: true
            allow_origin: ['^http://localhost:[0-9]+']
            allow_headers: ['X-Custom-Auth']
            allow_methods: ['POST', 'PUT', 'GET', 'DELETE']
            max_age: 3600
            hosts: ['^api\.']
Mon htaccess a bien la ligne :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
Header set Access-Control-Allow-Origin: *
Les entêtes de la requète POST :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
Request URL:https://{url}/api/en/pdfproducts
Request Method:POST
Status Code:200 OK
Remote Address:{ip}:443
Response Headers
view source
Cache-Control:private, must-revalidate, post-check=0, pre-check=0, max-age=1
Connection:keep-alive
Content-Description:File Transfer
Content-Disposition:attachment; filename="technicalSheet.pdf"
Content-Transfer-Encoding:binary
Content-Type:application/pdf
Date:Thu, 24 Nov 2016 13:23:21 GMT
Expires:Sat, 26 Jul 1997 05:00:00 GMT
Last-Modified:Thu, 24 Nov 2016 13:23:21 GMT
Pragma:public
Server:nginx
Transfer-Encoding:chunked
X-Powered-By:PleskLin
X-Powered-By:PHP/5.6.28
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, br
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Connection:keep-alive
Content-Length:1192
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryXClElLoLcyJwW8ZM
Host:{host}
Origin:https://{url}
Referer:https://{url}
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36
J'ai essayé pas mal de trucs mais rien n'y fait. Si quelqu'un a une idée

D'avance merci