fix: Resolve port conflict causing Railway healthcheck failure

Flask API was using PORT env variable which Railway also assigns to
the frontend static server. Both services were competing for the same
port, causing the container to fail health checks.

Changed Flask to use FLASK_PORT (default 5000) so it runs independently
from the Railway-assigned PORT used by the serve command.

https://claude.ai/code/session_01YEMFAbGgf8K7as4Uqgjv3R
This commit is contained in:
Claude 2026-01-29 21:52:27 +00:00
parent dac7677fcf
commit bf9b4cd3c4
No known key found for this signature in database
2 changed files with 6 additions and 1 deletions

View file

@ -59,7 +59,10 @@ serve dist -l ${PORT:-3000}\n\
EXPOSE 3000 5000
# Environment variables
# PORT is used by serve for the frontend (Railway will set this)
ENV PORT=3000
# FLASK_PORT is used by the Python API server (separate from Railway's PORT)
ENV FLASK_PORT=5000
ENV FLASK_DEBUG=false
ENV VITE_LATEX_API_URL=http://localhost:5000

View file

@ -332,6 +332,8 @@ def get_field_mapping(template_name):
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
# Use FLASK_PORT to avoid conflict with Railway's PORT variable
# which is used by the frontend static file server
port = int(os.environ.get('FLASK_PORT', 5000))
debug = os.environ.get('FLASK_DEBUG', 'false').lower() == 'true'
app.run(host='0.0.0.0', port=port, debug=debug)