Zouclar / MyShop

MyShop is a simple Symfony application between Shop and Products
0 stars 1 forks source link

CORS problem on ApiPlatform Admin #3

Closed Zouclar closed 3 years ago

Zouclar commented 3 years ago

Bonjour,

J'ai un problème concernant API Platform version ADMIN j'ai un soucis de CORS alors que j'ai bien suivi le tuto du coup je ne sais pas d'où viens le problème, si quelqu'un à une idée, je suis preneur.

Voici une capture d'écran de mon problème quand je tape sur l'administration. Capture d’écran de 2021-03-01 11-06-12

Zouclar commented 3 years ago

En fait il fallait suprimé le dernier "/" dans le fichier de config de nelmio_cors.yaml et transformé le fichier : de: '^/api/': à: '^/api':

Comme cela:

//config/packages/nelmio_cors.yaml

nelmio_cors:
    paths:
        '^/api':
            origin_regex: true
            allow_origin: ['^http://localhost:[0-9]+'] # You probably want to change this regex to match your real domain
            allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
            allow_headers: ['Content-Type', 'Authorization']
            expose_headers: ['Link']
            max_age: 3600