Self hosted Github login

I’m trying to get Netlify CMS to work on Vercel with Next.js.

To do this I’ve created two API routes in my Next.js, one for Auth that redirect me to Github, and a callback.

Both of these work without any further setup when developing locally, but as soon as my site is live on Vercel, the Login with Github button on Netlify CMS redirects me to

Could someone explain to me why that’s happening?

The following config works locally, but not in production:

  name: github
  repo: creativiii/wordpress-react
  branch: feature/netlify-cms

I’ve tried a bunch of combinations of configs with base_url, auth_endpoint and api_root but none of them have worked.

Any tips on how to get the Login with Github button to simply redirect me to https://<current-domain>/api/auth?

Is there also any way to use a JS file for the CMS’ config rather than a yaml one? I think this could be easy to fix if I could use env variables.

So as I thought the problem was caused by deploying my site to a preview URL and netlify cms not allowing a way to set ‘current site’ as base_url. So I just set all my preview deploys to be displayed at and set that as my base. Then I manually set my auth_endpoint to /api/auth and it started working.

1 Like

Thanks for coming back and sharing this update with us, @creativiii! This will definitely be beneficial to future Forums members. :netliconfetti: