immobiliare / backstage-plugin-gitlab

Backstage plugins to interact with GitLab
Apache License 2.0
115 stars 39 forks source link

Using the plugin in an environment with a basePath doesn't work #263

Closed gabrielhuber closed 11 months ago

gabrielhuber commented 1 year ago

Using the plugin in an environment with a baseUrl seems not to work. I tried to deploy the plugin to a backstage installation with for example this baseUrl: https://mykuberneteshost.de/subpath/backstage/... using a selfhosted gitlab installation with this url: https://mygitlabinstallation.de/

On startup the plugin creates a Proxy rewrite rule with this log message: Proxy rewrite rule created "^/subpath/backstage/api/gitlab/mygitlabinstallation.de/" ->"/api/v4"

But this Proxy rewrite rule seems to be wrong. When I try to open https://mykuberneteshost.de/subpath/backstage/api/gitlab/mygitlabinstallation.de/projects/my-group%2Fmyproject the redirect tries to open https://mygitlabinstallation.de/... instead of https://mygitlabinstallation.de/api/v4/...

I found a solution that worked for me, but I'm not sure if it is correct in any case. I copied the source code an rewrote the file https://github.com/immobiliare/backstage-plugin-gitlab/blob/main/packages/gitlab-backend/src/service/router.ts. There I removed the ${basePath} from the pathRewrite. Line 61 and 63: pathRewrite: {

            },

instead of: pathRewrite: {

            },
antoniomuso commented 1 year ago

Have you defined integrations.gitlab[0].apiBaseUrl variable in app-config.yaml?

gabrielhuber commented 1 year ago

My configuration look like that: app-config.yaml:

...
backend:
  baseUrl: https://https://mykuberneteshost.de/subpath/backstage
  ...

integrations:
  gitlab:
    - host: mygitlabinstallation.de
      token: ${GITLAB_TOKEN}
      apiBaseUrl: https://mygitlabinstallation.de/api/v4/
      baseUrl: https://gitlab.idst.ibaintern.de/
...
antoniomuso commented 1 year ago

baseUrl seems wrong formatted

gabrielhuber commented 1 year ago

You are right, in the comment, the baseUrl is wrong formatted. In the application there isn't this mistake. In the comment the baseUrl should be like this: backend.baseUrl: https://mykuberneteshost.de/subpath/backstage

github-actions[bot] commented 11 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.