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
nelmio/cors-bundle: update CORS_ALLOW_ORIGIN #487
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
|
/cc @dunglas ? |
Use single quotes around the value instead? |
but it's not generated like that, so default code is invalid currently. |
wait, we can put the single quotes in the recipe yes. Not sure we prefer one or another actually.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request passes validation.
works 👌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you check if it works with Docker Compose too please?
Hm, not sure actually. Im using https://github.com/lando/lando and i see it generates the following
Starting it already screams:
But other values are also wrapped in single quotes 🤔
With single quotes it seems the |
There's only one valid and supported way to parse a .env file, it's with a shell - ie |
Tend to agree.. not sure if this is tied to Docker or Lando though. So @dunglas can you confirm it still works for you? I can only say sourcing the current value doesnt. |
$ docker run -it --rm --env-file .env bash:4.4
bash-4.4# echo $CORS_ALLOW_ORIGIN
'^https?://localhost(:[0-9]+)?$' That's wrong at least. |
Does |
Not really :( $ source .env
$ echo $CORS_ALLOW_ORIGIN
^https?://localhost(:[0-9]+)?$
$ docker run -it --rm --env-file .env bash:4.4
bash-4.4# echo $CORS_ALLOW_ORIGIN
^https?://localhost\(:[0-9]+\)?$ |
Forwarding env does work 🤷♂️ export CORS_ALLOW_ORIGIN
$ echo $CORS_ALLOW_ORIGIN
^https?://localhost(:[0-9]+)?$
$ docker run -it --rm --env CORS_ALLOW_ORIGIN bash:4.4
bash-4.4# echo $CORS_ALLOW_ORIGIN
^https?://localhost(:[0-9]+)?$ |
Sure: the issue is the .env parser they use. Once the env var is set, it is not parsed anymore. |
Think so, per https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file
I think "simple" is key here... |
To move forward.. big 👍 for being compatible with sourcing manually. We can keep the default in the recipe "simple" maybe, to serve both users. More structurally, perhaps clarify this with a comment on top in the generated env files. Mentioning the escaping / docker traps. |
I'm wondering: how do rails' and nodejs' dotenv parse .env files? Do they all parse shell-like or are we the only ones? |
It looks like both nodejs and rails support single and double quoted strings:
|
i've concluded sharing .env between different concepts (Symfony and Docker) is a bad practice, or impractical at least. For anyone coming here from google&co, i advise to move docker-compose out of the project root to a dedicated scoped devops/docker folder. Closing as such. |
fixes
with
source .env
after
let me know if im missing something 🤔