Skip to content

Plugin Fails Behind Reverse Proxy with Subpath #975

@Imtehariya

Description

@Imtehariya

Problem

The GitLab plugin doesn't work when Backstage runs behind a reverse proxy with a subpath (e.g., /my-app/dev). The pathRewrite patterns can't match because the subpath is stripped before reaching the plugin.

Environment:

  • Backstage: 1.44.2
  • Backend URL: https://domain.com/my-app/dev

What Happens

Request sent: /my-app/dev/api/gitlab/rest/gitlab.com/api/v4/projects/123

Plugin receives: /rest/gitlab.com/api/v4/projects/123

Result: The subpath is lost, causing pathRewrite to fail → GitLab returns 404

Root Cause

Backstage's httpRouter mounts plugins at /api/{pluginId}, removing the upstream subpath before plugin middleware runs.

Workaround

Create a custom httpRouter service factory that restores the full path (with subpath) into req.originalUrl.

Proposed Solutions

  1. Auto-detect base path from backend.baseUrl config
  2. Add config option:
    gitlab:
      basePath: /my-app/dev
  3. Use relative paths in pathRewrite (no subpath needed)

Impact

Affects all Backstage deployments using reverse proxies (Nginx, Istio, etc.) with URL subpaths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions