decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.96k stars 3.05k forks source link

GET request to GitHub specifies "repositories" instead of "repos" in the path #5687

Open tforster opened 3 years ago

tforster commented 3 years ago

Describe the bug Trying out Netflify CMS using the index.html demo page. Admin UI loads without issue but publishing content results in a 404 in the browser console

GET https://api.github.com/repositories/tforster/netlify-poc/branches/main 404

cURLing that endpoint also produces a 404. According to the GitHub docs repositories should be repos. cURLing the corrected URL returns the expected JSON response.

# Using /repos/ in the path works
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repos/tforster/netlify-poc/branches/main

To Reproduce

Either navigate in a browser to the URL that Netflify CMS was trying to reach https://api.github.com/repositories/tforster/netlify-poc/branches/main

or try the following

# Using /repositories/ in the path fails with a 404
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/repositories/tforster/netlify-poc/branches/main

Applicable Versions: Have used both the following script references, all produce the same erroneous behaviour

CMS configuration

backend:
  name: github
  repo: tforster/netlify-poc
  api_root: https://api.github.com
  site_domain: cms.netlify.com
  base_url: https://api.netlify.com
  auth_endpoint: auth

media_folder: static/img
public_folder: /img

collections:

<snip>
erezrokah commented 3 years ago

Hi @tforster, I'm not sure where repositories is coming from as we use repos: https://github.com/netlify/netlify-cms/blob/fc2e3106bbf6dea02be6842d285bc310c2479450/packages/netlify-cms-backend-github/src/API.ts#L202

Also when using the GitHub backend your configuration should be:

backend:
  name: github
  repo: tforster/netlify-poc

when using Netlify as an authentication provider per the docs.

When using an external authentication provider, you should configure it based on the instructions of the client you chose.

In any case, you should not use site_domain: cms.netlify.com as the cms.netlify.com authentication provider is only intended for local development.