Skip to content

Conversation

@sonarta
Copy link
Contributor

@sonarta sonarta commented Sep 3, 2025

Description

This PR fixes an issue where environment variables from .env were not being properly loaded in Docker containers.

Changes Made

  • Moved dotenv.config() to the top of server.js to ensure environment variables are loaded before other modules
  • Updated docker-compose.yml to properly handle .env file
  • Removed duplicate environment variables section

Testing

  • Tested locally with Docker
  • Verified BASE_PATH and TRUST_PROXY work as expected
  • Confirmed no breaking changes to existing functionality

Notes

This change ensures consistent behavior between local development and Docker environments.

sonarta and others added 3 commits September 1, 2025 15:45
- Move dotenv config to the top of server.js
- Update docker-compose.yml to properly handle .env file
- Remove duplicate environment variables section

This ensures BASE_PATH and TRUST_PROXY work as expected in both Docker and local environments.
@avoylenko avoylenko merged commit 364c8fe into avoylenko:main Sep 6, 2025
1 check passed
@devsynck
Copy link

@sonarta I didn’t want to open a new issue just for this, but I noticed that unless BASE_PATH and TRUST_PROXY are commented out in the .env file, routing inside the Docker container breaks.

@sonarta
Copy link
Contributor Author

sonarta commented Sep 16, 2025

@sonarta I didn’t want to open a new issue just for this, but I noticed that unless BASE_PATH and TRUST_PROXY are commented out in the .env file, routing inside the Docker container breaks.

Thanks for the feedback! You're absolutely right. The BASE_PATH and TRUST_PROXY environment variables are designed for deployments behind a reverse proxy or load balancer. When running in a Docker container without such setup, these can cause routing issues.

To resolve this, users should comment out both variables in their .env file when deploying with Docker. For example:

# BASE_PATH=/api
# TRUST_PROXY=true

This ensures the app runs correctly in containerized environments. If you have any other suggestions or encounter similar issues, feel free to share!

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

Successfully merging this pull request may close these issues.

3 participants