Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: multiple allow_origin entries #199

Closed
ThePeterMick opened this issue May 14, 2024 · 2 comments
Closed

Question: multiple allow_origin entries #199

ThePeterMick opened this issue May 14, 2024 · 2 comments

Comments

@ThePeterMick
Copy link

Version

2.4

Question

I'm trying to pass in multiple allow_origin hostnames via .env file

.env:
CORS_ALLOW_ORIGIN='["http://localhost:3001","http://localhost:3002"]'

nelmio_cors.yaml
allow_origin: ['%env(json:CORS_ALLOW_ORIGIN)%']

but it keeps failing

when I do this in nelmio_cors.yaml, it works fine:
allow_origin: ['http://localhost:3001','http://localhost:3002']

Did anyone come across this? TIA 🙏

How could one pass in multiple entries to allow_origin from .env? I'm out of ideas, ChatGPT+ is out of ideas too...

Additional context

Even GPT-4o thinks this should work, but sadly it doesn't (explored different options with ChatGPT too 🫠)

@Seldaek
Copy link
Member

Seldaek commented Jun 24, 2024

I think if anything allow_origin: '%env(json:CORS_ALLOW_ORIGIN)%' without the [] around might work, but I guess this requires delayed param handling, while this bundle still does it the old school way and computes stuff in the DI Extension which is too early as env vars are not available at that time.

I agree it'd be nice but this is some amount of refactoring I don't have time for unfortunately.

@Seldaek
Copy link
Member

Seldaek commented Jun 24, 2024

Actually sorry, closing as duplicate of #148 and see #188 for a fix which I need to merge.

@Seldaek Seldaek closed this as completed Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants