How to expose env vars to middleware when running next app in Docker
Answered
Bonga shad posted this in #help-forum
Bonga shadOP
I want to access .env.local file variables in middleware for auth purposes. It seems like the env var is not available? How can I set this in my dockerfile?
Answered by Bonga shad
I have fixed that by loading.env file through docker compose yaml. It was required for runtime environment.
5 Replies
@Bonga shad I want to access .env.local file variables in middleware for auth purposes. It seems like the env var is not available? How can I set this in my dockerfile?
If its in production, I think you should just use
And I'm not sure if thats expected. Can you try renaming file to
.env.And I'm not sure if thats expected. Can you try renaming file to
.env, and use docker to create a production server, and see if it works?Bonga shadOP
I have fixed that by loading.env file through docker compose yaml. It was required for runtime environment.
Answer
@Bonga shad I have fixed that by loading.env file through docker compose yaml. It was required for runtime environment.
mark this message as a solution
Bonga shadOP
@"use php" how do I do that?
Original message was deleted
Refer to this message