Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend for self-hosted Gitlab still queries gitlab.com #7168

Open
JbIPS opened this issue Apr 9, 2024 · 3 comments · May be fixed by #7214
Open

Backend for self-hosted Gitlab still queries gitlab.com #7168

JbIPS opened this issue Apr 9, 2024 · 3 comments · May be fixed by #7214
Labels
type: bug code to address defects in shipped code

Comments

@JbIPS
Copy link

JbIPS commented Apr 9, 2024

Describe the bug
I configured a backend for my hosted version of Gitlab

  name: gitlab
  repo: web/landing
  auth_type: pkce # Required for pkce
  app_id: *******
  api_root: https://gitlab.****/api/v4
  base_url: https://gitlab.*****
  auth_endpoint: oauth/authorize

On login:

  • I get rediricted to my hosted app ✔️
  • a call is made to GET https://gitlab.*****/api/v4/projects/web%2Flanding ✔️
  • then a call to GET https://gitlab.com/api/v4/projects/web%2Flanding

Of course the 3rd call gives a 404 and login workflow stops.

I looked at the sources but couldn't find a static ref to gitlab.com.

To Reproduce

  1. Configure a backend for a hosted gitlab
  2. Try to login

Expected behavior
No call should be made to gitlab.com

Screenshots
Screenshot from 2024-04-09 17-50-08

Applicable Versions:

CMS configuration

collections:
  - name: 'posts'
    label: "Posts de blog"
    folder: "blog/posts"
    create: true
    fields:
      - { label: "Layout", name: "layout", widget: "hidden", default: "post"}
      - { label: "Titre", name: "title", widget: "string"}
      - { label: "Image", name: "image", widget: "image"}
      - { label: "Miniature", name: "thumbnail", widget: "image"}
      - { label: "Categorie", name: "categoriy", widget: "string"}
      - { label: "Résumé", name: "excerpt", widget: "markdown"}
      - { label: "Contenu", name: "body", widget: "markdown"}

locale: fr

media_folder: "assets/posts"
backend:
  name: gitlab
  repo: web/landing
  auth_type: pkce # Required for pkce
  app_id: *******
  api_root: https://gitlab.****/api/v4
  base_url: https://gitlab.*****
  auth_endpoint: oauth/authorize
@JbIPS JbIPS added the type: bug code to address defects in shipped code label Apr 9, 2024
@yuchi
Copy link

yuchi commented May 20, 2024

Probably the issue happens when calling getDefaultBranchName without passing all backend configuration options.

Indeed if you add branch: master (or whatever you need) to the backend configuration it will work.

@JbIPS
Copy link
Author

JbIPS commented May 21, 2024

You're right, it looks like the API roots are hard-wired into decap-cms-lib-util.

And setting the branch in my YAML do the trick, thanks a lot! 🥳

Should I create a PR to pass an optional api_root to getDefaultBranch and apiRequest ? If present, this line will use it as-is instead.

@martinjagodic
Copy link
Member

@JbIPS a PR would be helpful, thanks!

JbIPS added a commit to JbIPS/decap-cms that referenced this issue May 23, 2024
In case of a self-hosted Gitlab, the API request to get the default
branch always call gitlab.com.
This commit allow to pass a custom API root from the config to the API
call.

Fix decaporg#7168
@JbIPS JbIPS linked a pull request May 23, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants