loblaw-sre / backstage-plugin-gitlab

Backstage plugin for Gitlab
52 stars 31 forks source link

Returns 404 when running on azure app service #114

Open naramck opened 2 years ago

naramck commented 2 years ago

I added the plugin to a backstage instance running on azure app service as docker container. The plugin returns 404 hitting https://my.domain.com/api/proxy/gitlabci/projects/gitlabgroup%2Fprojectname.

I verified the proxy works fine when I hit https://my.domain.com/api/proxy/test which goes to example.com. I am seeing in the logs that returned 404 the url shown as https://my.domain.com/api/proxy/gitlabci/projects/gitlabgroup/projectname. I am not sure if the forward slash is the issue.

It works locally on my machine when using separate port for backend. Can you please let me know if there is anything I have to do for running this plugin?

thank you.

satrox28 commented 2 years ago

Hi @naramck

Please make sure of the access token used for the proxy can read those projects.

curl --request GET --header "PRIVATE-TOKEN: " https://gitlabhost.com/api/v4/projects/

satrox28 commented 2 years ago

@naramck were you able to resolve the issue?.

naramck commented 2 years ago

Hi @satrox28, The issue still exists. I tested the curl command. The proxy token has access to the projects. Seems like the backend proxy api call returning 404, its not even reaching to the gitlab client that is running on backstage backend api.

naramck commented 2 years ago

@satrox28,

This seems to be an issue with proxy plugin. The url that is being sent to proxy from browser (GitlabCIClient) is shown as backstage.domain/api/proxy/gitlabci/group%2Fprojectname. but the proxy converts %2F to a forward slash and tries to send that URL to gitlab rest api which returns 404.

satrox28 commented 2 years ago

Hi @naramck

Can you change it to project id in annotation and try.

satrox28 commented 2 years ago

Hi @naramck Any update?

naramck commented 2 years ago

HI @satrox28, It is still an open issue. I spent bit of time, and based on what i observed, the issue seems to be in http-proxy-middleware.

satrox28 commented 2 years ago

@naramck

were you able to check if the below proxy config for gitlabci exist on app-config.yaml?.

  '/gitlabci':
    target: https://gitlab.com/api/v4 or change to your custom gitlab host
    allowedMethods: ['GET']
    headers:
      PRIVATE-TOKEN: '<TOKEN>'
naramck commented 2 years ago

@satrox28 yes, i have the correct config and token.