Skip to content

[BUG]: Playwright tests fail with 404 on path-prefixed deployments due to absolute URL paths #4623

@ChrisPC-39

Description

@ChrisPC-39

🐞 Bug Summary

Playwright test suite fails with "404 default backend" errors when running against path-prefixed deployments. APIRequestContext resolves absolute URL paths (starting with /) from domain root instead of from base_url, causing API calls to hit wrong endpoints.


🧩 Affected Component

Select the area of the project impacted:

  • mcpgateway - API
  • mcpgateway - UI (admin panel)
  • mcpgateway.wrapper - stdio wrapper
  • Federation or Transports
  • CLI, Makefiles, or shell scripts
  • Container setup (Docker/Podman/Compose)
  • Other (explain below)

Playwright test suite


🔁 Steps to Reproduce

  1. Deploy MCP Gateway to environment with path prefix set in APP_ROOT_PATH (e.g., /test)
  2. Configure Playwright tests with path-prefixed base_url
  3. Run Playwright tests, e.g: pytest tests/playwright/test_admin_ui.py
    Observe test failures with "404 default backend" errors

🤔 Expected Behavior

APIRequestContext calls should resolve relative to the configured base_url, regardless of whether the deployment uses a path prefix. Tests using api_request_context.post("/teams/") should hit {base_url}/{app_root_path}/teams/, not {base_url}/teams/.


📓 Logs / Error Output

FAILED tests/playwright/test_rbac_permissions.py::TestRBACGatewayCreate::test_admin_create_gateway_all_teams_view[chromium]
AssertionError: Failed to create team: 404 default backend - 404

Error at line 208:
assert resp.ok, f"Failed to create team: {resp.status} {resp.status_text} - {resp.text()}"

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingplaywrightAutomated UI testing with playwrighttriageIssues / Features awaiting triage

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions