Skip to content

Conversation

ESnark
Copy link

@ESnark ESnark commented Sep 1, 2025

πŸ› Bug-fix PR

Before opening this PR please:

  1. make lint - passes ruff, mypy, pylint
  2. make test - all unit + integration tests green
  3. make coverage - β‰₯ 90 %
  4. make docker docker-run-ssl or make podman podman-run-ssl
  5. Update relevant documentation.
  6. Tested with sqlite and postgres + redis.
  7. Manual regression no longer fails. Ensure the UI and /version work correctly.

πŸ“Œ Summary

This PR fixes static file serving when APP_ROOT_PATH is configured, ensuring that static assets (CSS, JS) are correctly
mounted and accessible when the application is deployed behind a reverse proxy with a custom base path.

πŸ” Reproduction Steps

  1. Deploy MCP Gateway behind a reverse proxy with APP_ROOT_PATH=/gateway
  2. Access the Admin UI at /gateway/admin
  3. Static assets fail to load with 404 errors (e.g., /static/admin.css instead of /gateway/static/admin.css)

🐞 Root Cause

When APP_ROOT_PATH was configured for reverse proxy deployments, static files were still mounted at /static instead of {APP_ROOT_PATH}/static, causing the browser to request assets at the wrong path and resulting in 404 errors.

πŸ’‘ Fix Description

Modified the static file mounting logic to:

  • Mount static files at {APP_ROOT_PATH}/static when APP_ROOT_PATH is configured
  • Maintain backward compatibility by using /static when APP_ROOT_PATH is not set
  • Updated logging to clearly show the actual mount path for debugging

πŸ§ͺ Verification

Check Command Status
Lint suite make lint βœ…
Unit tests make test βœ…
Coverage β‰₯ 90 % make coverage βœ…
Manual regression no longer fails Tested with reverse proxy setup βœ…

πŸ“ MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

βœ… Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

@ESnark ESnark requested a review from crivetimihai as a code owner September 1, 2025 13:05
When APP_ROOT_PATH is set (e.g., /gateway), static files are now correctly
mounted at the appropriate path (e.g., /gateway/static) to work with
reverse proxy configurations.

- Mount static files at {APP_ROOT_PATH}/static when APP_ROOT_PATH is set
- Keep default /static mount when APP_ROOT_PATH is not set
- Update logging to show the actual static mount path

This fixes 404 errors when accessing admin.css and other static assets
in reverse proxy deployments.

Signed-off-by: ESnark <[email protected]>
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.

1 participant