Skip to content

fix(docker): make frontend accessible for PDF generation#724

Merged
srbhr merged 2 commits into
srbhr:mainfrom
chadidi:fix/frontend-port-binding
Apr 10, 2026
Merged

fix(docker): make frontend accessible for PDF generation#724
srbhr merged 2 commits into
srbhr:mainfrom
chadidi:fix/frontend-port-binding

Conversation

@chadidi
Copy link
Copy Markdown
Contributor

@chadidi chadidi commented Mar 23, 2026

Pull Request Title

Cannot connect to frontend for PDF generation

Related Issue

Description

image

I just cloned the repo today and started using docker compose up -d, when i tried to download the PDF i get this 503 error

{"detail":"Cannot connect to frontend for PDF generation. Attempted URL: http://localhost:3000/print/resumes/adabad6e-e484-467f-aa44-54ba0377e448?template=swiss-single&pageSize=A4&marginTop=10&marginBottom=10&marginLeft=10&marginRight=10&sectionSpacing=3&itemSpacing=2&lineHeight=3&fontSize=3&headerScale=3&headerFont=serif&bodyFont=sans-serif&compactMode=false&showContactIcons=false&accentColor=blue&lang=en. Please ensure: 1) The frontend is running, 2) The FRONTEND_BASE_URL environment variable in the backend .env file matches the URL where your frontend is accessible."}

Type

  • Bug Fix
  • Feature Enhancement
  • Documentation Update
  • Code Refactoring
  • Other (please specify):

Proposed Changes

  • Update start.sh to pass HOSTNAME=0.0.0.0 and PORT to Next.js server
  • Allow frontend to bind correctly inside single-container setup
  • Fix backend -> frontend communication (resume PDF export 503 error)
  • Support dynamic port via environment variables

Screenshots / Code Snippets (if applicable)

How to Test

  1. Pull the repo on MacBook M1 pro
  2. docker compose up -d
  3. Try to download PDF file

Checklist

  • The code compiles successfully without any errors or warnings
  • The changes have been tested and verified
  • The documentation has been updated (if applicable)
  • The changes follow the project's coding guidelines and best practices
  • The commit messages are descriptive and follow the project's guidelines
  • All tests (if applicable) pass successfully
  • This pull request has been linked to the related issue (if applicable)

Additional Information

copilot:walkthrough


Summary by cubic

Fixes 503 errors during PDF generation in Docker by making the frontend reachable from the backend. The Next.js server now binds to 0.0.0.0 on the configured port via exported env vars.

  • Bug Fixes
    • Export HOSTNAME="0.0.0.0" and PORT="$FRONTEND_PORT" in docker/start.sh for the Next.js standalone server.
    • Restores backend-to-frontend calls in single-container setups and supports dynamic ports.

Written for commit 2d0aac9. Summary will update on new commits.

- Update start.sh to pass HOSTNAME=0.0.0.0 and PORT to Next.js server
- Allow frontend to bind correctly inside single-container setup
- Fix backend -> frontend communication (resume PDF export 503 error)
- Support dynamic port via environment variables
Comment thread docker/start.sh Outdated

trap '' SIGTERM SIGINT SIGQUIT
node server.js "$@" &
HOSTNAME=0.0.0.0 PORT="${FRONTEND_PORT}" node server.js "$@" &
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: Redundant PORT assignment

The inline PORT="${FRONTEND_PORT}" is redundant since export PORT="${FRONTEND_PORT}" already sets this environment variable on line 236. The subshell inherits all exported variables, so this inline assignment is unnecessary.

Consider simplifying to:

Suggested change
HOSTNAME=0.0.0.0 PORT="${FRONTEND_PORT}" node server.js "$@" &
HOSTNAME=0.0.0.0 node server.js "$@" &

This keeps the critical HOSTNAME=0.0.0.0 fix (which is the actual solution to the 503 error) while removing the duplication.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Mar 23, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Overview

This PR correctly fixes the 503 error during PDF generation in Docker by adding HOSTNAME="0.0.0.0" to make the Next.js frontend server accessible from the backend container.

Key observations:

  • The fix is correct: Next.js standalone server requires both HOSTNAME and PORT environment variables to bind properly for external access
  • The export HOSTNAME="0.0.0.0" allows the frontend to accept connections from any network interface, enabling the backend to reach it for PDF rendering
  • Previous feedback about redundant PORT assignment has been addressed by the author
  • No API breaking changes, security concerns, or LiteLLM configuration issues
Files Reviewed (1 file)
  • docker/start.sh - 0 issues (correct fix for container networking)

Previous inline comment on redundant PORT assignment is now outdated - the author addressed it in commit 2d0aac9.


Reviewed by claude-4.5-opus-20251124 · 99,427 tokens

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@srbhr srbhr merged commit 5026ec0 into srbhr:main Apr 10, 2026
1 check passed
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.

2 participants