Blocking a CORS request [SYMFONY]

I work on Ionic and when I launch a request on my API (Symfony 5), both are local, I have this error:

enter image description here

On the Symfony side, I modified the .env by putting:

<php

CORS_ALLOW_ORIGIN=^https?://localhost:?[0-9]*$

And in nelmio_cors.yaml:

<php
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']
        max_age: 3600
    paths:
        '^/': ~

Despite this, I still get the same error.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *