decaporg / decap-cms

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

Login not working, with github account, when deploying on Vercel. #7321

Closed VojtechPetr closed 1 week ago

VojtechPetr commented 2 weeks ago

Hello, I already checked all the tickets, but so far didn't found a solution. Here the closest ticket (https://github.com/decaporg/decap-cms/issues/4731), that helped me to move a bit further, but didn't solved my problem

Describe the bug I created my config.yml and index.html files, in order to setup DecapCMS. Locally it was working fine, once deployed on Vercel, when I click on "Login with GitHub" I have a not found page. 382520944-669da8a9-5a32-4a45-8463-87717891f029

I tried to follow the description here and setup as well a backend service from here: https://github.com/vencax/netlify-cms-github-oauth-provider.

I deployed the backend service, in Vercel I setup these env. variables: obrazek which corresponds to the GitHUb OAuth app. The REDIRECT_URI in Vercel correspond to the Authorization callback URL in GitHub OAuth app "https://mebs-hodonin-oauth.vercel.app/callback". Am I overviewing something? Or where is the problem?

This is the console output: 382527192-803eafc2-4a81-455b-948d-79068ecb2771 Here translated -> 03:53:51.525 Redirected to https://www.bytovka.cz/admino/index.html 03:53:51.592 GET https://www.bytovka.cz/admino/index.html 03:53:51.723 GET https://www.bytovka.cz/admino 03:53:51.942 Removing unpermitted intrinsics 03:53:52.032 GET https://unpkg.com/decap-cms@^3.1.2/dist/decap-cms.js 03:53:52.717 GET https://unpkg.com/decap-cms@3.3.3/dist/decap-cms.js 03:53:53.644 GET https://www.bytovka.cz/favicon.ico 03:53:53.755 decap-cms-app 3.3.3 03:53:53.765 Unknown pseudo-class or pseudo-element “-ms-track”. Rule set ignored due to bad selector. 03:53:53.765 Unknown pseudo-class or pseudo-element “-ms-fill-lower”. Rule set ignored due to bad selector. 03:53:53.765 Unknown pseudo-class or pseudo-element “-ms-thumb”. Rule set ignored due to bad selector. 03:53:53.765 Unknown pseudo-class or pseudo-element “-ms-thumb”. Rule set ignored due to bad selector. 03:53:53.765 decap-cms-core 3.4.2 03:53:53.766 Using config file path: "https://www.bytovka.cz/admino/config.yml" 03:53:53.768 decap-cms 3.3.3 03:53:53.780 XHR GET https://www.bytovka.cz/admino/config.yml 03:53:54.318 Start ajax tracing with delay of '0'. 03:53:54.388 Source map error: Error: NetworkError when attempting to fetch resource. Source URL: https://unpkg.com/decap-cms@%5E3.1.2/dist/decap-cms.js Source map URL: decap-cms.js.map [Find out more]

Here my config.yml: backend: name: github repo: VojtechPetr/MeBS-Hodonin branch: main auth: client_id: 'Ov23li4P1rJmx2UWaWmP' scope: 'repo' base_url: 'https://mebs-hodonin-oauth.vercel.app' auth_endpoint: 'auth'

media_folder: 'public/assets/images' public_folder: 'src/assets/images'

collections: ...

And here my index.html: obrazek

I setup one of the OAuth Client as described here but didn't worked so far: https://decapcms.org/docs/external-oauth-clients/

To Reproduce Deploy your web project on Vercel. The login to Decap CMS won't work with github login.

Expected behavior I should be able to login with github user credentials

Applicable Versions:

4www commented 2 weeks ago

Hello,

not sure what is going on in your case, but not sure it is a bug from the CMS.

It seems that the decapCMS is not finding your base_url configuration.

Are you sure that you need the auth object in your backend configuration?

I've tried an example configuration for your site: https://jsbin.com/wecirebece/2/edit?html,output

So if you have this currently:

backend:
  name: github
  repo: VojtechPetr/MeBS-Hodonin
  branch: main
  auth: ← Here, do we need this object nesting?
    client_id: 'Ov23li4P1rJmx2UWaWmP'
    scope: 'repo'
    base_url: 'https://mebs-hodonin-oauth.vercel.app'
    auth_endpoint: 'auth'

Maybe something like that? I cannot find the auth part in decap cms github backend config (or any other)

backend:
  name: github
  repo: VojtechPetr/MeBS-Hodonin
  branch: main
  client_id: 'Ov23li4P1rJmx2UWaWmP'
  scope: 'repo'
  base_url: 'https://mebs-hodonin-oauth.vercel.app'
  auth_endpoint: 'auth'

Screenshot from 2024-11-04 08-43-01

VojtechPetr commented 1 week ago

I close this issue, since isn't a bug. Anyway @4www thank you for the support. Maybe will help somebody in the future.