{"id":15020975,"url":"https://github.com/digitalinteraction/vercel-netlify-cms-github","last_synced_at":"2025-10-27T01:30:33.334Z","repository":{"id":262331230,"uuid":"332037776","full_name":"digitalinteraction/vercel-netlify-cms-github","owner":"digitalinteraction","description":"Vercel API routes to login to netlify-cms with GitHub","archived":false,"fork":true,"pushed_at":"2022-01-13T15:54:06.000Z","size":18,"stargazers_count":22,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-12T10:47:00.033Z","etag":null,"topics":["netlify-cms","vercel","vercel-endpoint"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@openlab/vercel-netlify-cms-github","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"typeofweb-org/vercel-netlify-cms-github","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalinteraction.png","metadata":{},"created_at":"2021-01-22T19:04:02.000Z","updated_at":"2024-11-08T12:31:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/digitalinteraction/vercel-netlify-cms-github","commit_stats":null,"previous_names":["digitalinteraction/vercel-netlify-cms-github"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fvercel-netlify-cms-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fvercel-netlify-cms-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fvercel-netlify-cms-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalinteraction%2Fvercel-netlify-cms-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalinteraction","download_url":"https://codeload.github.com/digitalinteraction/vercel-netlify-cms-github/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238418217,"owners_count":19468865,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["netlify-cms","vercel","vercel-endpoint"],"created_at":"2024-09-24T19:55:57.968Z","updated_at":"2025-10-27T01:30:33.287Z","avatar_url":"https://github.com/digitalinteraction.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vercel-netlify-cms-github\n\nAn NPM package to allow you to use netlify-cms with GitHub authentication\nwhen deploying on Vercel.\n\n## Installation\n\n**1. Install the module**\n\n```bash\n# cd into/your/vercel/project\nnpm install @openlab/vercel-netlify-cms-github\n```\n\n**2. Create the auth route**\n\nCreate a vercel endpoint at `api/auth.ts`\n\n```ts\nexport { auth as default } from '@openlab/vercel-netlify-cms-github'\n```\n\n**3. Create the callback route**\n\nCreate a vercel endpoint at `api/callback.ts`\n\n```ts\nexport { callback as default } from '@openlab/vercel-netlify-cms-github'\n```\n\n**4. Update your config.yml**\n\nUpdate your `config.yml` to include this backend\n\n```yaml\nbackend:\n  name: github\n  repo: YOUR_GITHUB_REPO\n  base_url: YOUR_WEBSITE\n  auth_endpoint: api/auth\n```\n\n- **repo** should be your GitHub repo path, like `owner/repo`\n- **base_url** should be the full url to the root of your site, like `https://example.com/`\n- **auth_endpoint** needs to be set to link it up correctly, you can't put it in `base_url`\n\n**(optional) Configure vercel.json**\n\nIf you have your admin files in a folder (e.g. `admin/index.html` and `admin/config.yml`)\nyou might want to force vercel to use trailing slashes.\nThis is because if you visit `/admin` netlify will look for a config at `/config.yml`,\nnot in the admin folder.\n\nTo solve this add (or update) your [vercel.json](https://vercel.com/docs/configuration)\nin the project root:\n\n```json\n{\n  \"trailingSlash\": true\n}\n```\n\n**5. Commit these endpoints to git**\n\n```bash\ngit add api/auth.ts api/callback.ts\ngit commit -m \":star: add GitHub auth routes and connect to netlify-cms\"\n```\n\n**6. Create a GitHub OAuth application**\n\nGo to https://github.com/settings/developers.\n\n- Set **Homepage URL** to your site's homepage\n- Set **Authorization callback URL** to `https://YOUR_SITE_HERE/api/callback\n- Make a note of your `client_id` and `client_secret`\n\n**7. Setup Vercel environment variables**\n\nGo to your vercel dashboard, https://vercel.com.\n\n- Navigate to your project then **Settings** \u003e **Environment Variables**\n- Add `OAUTH_CLIENT_ID` and set the value from the GitHub OAuth application\n- Add `OAUTH_CLIENT_SECRET` and set the value from the GitHub OAuth application\n- You can store them however you like but secrets should be the most secure\n- Make sure your environment variables are exposed on the deployment(s) you need\n\n**Done**\n\n🎉 Your site should now be linked up!\n\n## Configuration\n\n**Environment Variables**\n\nIn addition to `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET`,\nthis package also exposes these variables to configure the GitHub authentication.\nThese all have default values configured to talk to github.com.\n\n- `OAUTH_HOST` (default: `https://github.com`)\n  The GitHub server to talk to\n- `OAUTH_TOKEN_PATH` (default: `/login/oauth/access_token`)\n  The path of the GitHub OAuth\n  [token endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.2)\n- `OAUTH_AUTHORIZE_PATH` (default: `/login/oauth/authorize`)\n  The path of the GitHub OAuth\n  [Authorization endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.1)\n\n## API usage\n\nOther than the Vercel endpoints, these are exported:\n\n- `oauthConfig` is an object with configuration for [simple-oauth2](https://www.npmjs.com/package/simple-oauth2)\n- `randomState` is a function to generate a random state for an OAuth2 flow\n- `renderResponse` is a function to generate HTML with client-side JavaScript\n  to complete the OAuth2 flow using `window.opener.postMessage`\n\n\u003e These were primarily exposed for\n\u003e [digitalinteraction/netlify-cms-github-auth](http://github.com/digitalinteraction/netlify-cms-github-auth)\n\u003e to use.\n\n---\n\n\u003e This project was set up by [puggle](https://npm.im/puggle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fvercel-netlify-cms-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalinteraction%2Fvercel-netlify-cms-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalinteraction%2Fvercel-netlify-cms-github/lists"}