Your GitHub token is in the frontend: how to find it, revoke it and keep it on the server
Updated 5 December 2026
If your Lovable, Bolt, v0 or Vite app talks to GitHub from the browser, the personal access token is in the JavaScript that every visitor downloads. That is already a leak. A token can read or write the repositories and account data it was granted, and a classic personal access token can be as powerful as your own GitHub login, limited only by the scopes you ticked. GitHub's docs say to treat access tokens like passwords, never hardcode them in your code, and never push unencrypted credentials to any repository, even a private one. This guide is the GitHub-specific version of that check: how to confirm the token is in the live bundle, what to do first, and where the call should live instead.
Check your own app for this, free.
Paste your live URL. ShipCheck looks for leaked API keys in your page and JavaScript, exposed files like /.env and /.git, missing security headers, SSL certificate problems, domain expiry (custom domains only) and what Google sees without running JavaScript. You'll see your score without signing up.
Short answer
A GitHub token must never ship in the frontend. That includes classic personal access tokens (ghp_), fine-grained personal access tokens (github_pat_), and the other official prefixes (gho_, ghu_, ghs_, ghr_). Putting one in VITE_GITHUB_TOKEN or NEXT_PUBLIC_GITHUB_TOKEN does not hide it: Vite and Next.js copy those values into the public bundle at build time. If you find one, delete it first in your GitHub settings, then move any GitHub call into a server function and store the replacement only as a server-side secret. A key prefix check (nothing leaves your browser) will tell you whether the string starts like a GitHub token. For the same check across other providers, see how to check for leaked API keys.
How to check the live app
Check the deployed URL, not only the editor preview.
- Search the JavaScript. Open the live site, press F12, go to Sources, and search all files (Ctrl+Shift+F, or Cmd+Option+F on a Mac) for
ghp_,github_pat_,gho_,ghu_,ghs_,ghr_andapi.github.com. Click the GitHub-connected feature first, because some chunks only load then. - Watch the Network tab. Use that feature. If the browser sends a request straight to
api.github.comwith anAuthorization: Bearer …orAuthorization: token …header, the secret is in the frontend, even if the text search missed it. - Or grep the scripts linked from the page:
URL=https://your-app.com for js in $(curl -s "$URL" \ | grep -oE 'src="[^"]+\.js[^"]*"' | cut -d'"' -f2); do case "$js" in http*) u="$js";; /*) u="$URL$js";; *) u="$URL/$js";; esac curl -s "$u" | grep -oE 'gh[pousr]_[A-Za-z0-9]{8,}|github_pat_[A-Za-z0-9_]{8,}' \ | cut -c1-14 | sort -u doneThis prints only the start of a match, so you are not pasting a full token into your terminal history. A clean result is not proof: it only covers scripts linked from the HTML, not code that loads later.
Not sure what you found? Type just the first few characters into the is this key safe? tool. Do not paste the whole token.
The official prefixes
GitHub issues tokens that start with a prefix so you can tell the type. The official list is in About authentication to GitHub:
| Prefix | Token type |
|---|---|
ghp_ | Personal access token (classic) |
github_pat_ | Fine-grained personal access token |
gho_ | OAuth access token |
ghu_ | GitHub App user access token |
ghs_ | GitHub App installation token |
ghr_ | GitHub App refresh token |
None of these belong in browser code. A fine-grained token is narrower than a classic one, and GitHub recommends fine-grained tokens when they can do the job, but it is still a secret. If it is in the frontend, anyone who loads the page can use whatever repositories and permissions it has.
Why this happens in vibe-coded apps
The usual prompt is “connect this app to my GitHub” or “list my repos”, plus a token in an environment variable. Frontend build tools then bake any public-prefixed variable into the JavaScript:
- Vite (most Lovable and Bolt apps): variables starting with
VITE_are exposed in client-side source after the build. Vite's docs sayVITE_*variables should not contain sensitive information such as API keys, and recommend a backend or serverless/edge function for secrets. See Vite: Env Variables and Modes. - Next.js (v0, many Cursor apps): variables starting with
NEXT_PUBLIC_are inlined into the client bundle at build time. A variable namedGITHUB_TOKEN, without that prefix, stays on the server. See Next.js environment variables.
Renaming the variable, splitting the token, or “hiding” it in a client helper does not help. The browser has to send the real token to GitHub, so anyone can copy it from the Network tab.
If the app only reads public repositories, you often do not need a token at all: the GitHub API accepts unauthenticated requests for public data, with a lower rate limit. A token in the frontend is not a safe way to raise that limit.
If the token already leaked, do this in order
- Delete the exposed token first. Pausing or taking down the app does not stop anyone: the token works without your site. In GitHub, go to Settings → Developer settings → Personal access tokens, open Fine-grained tokens or Tokens (classic) depending on the prefix, and delete the exposed token. Official steps are in Managing your personal access tokens. For an OAuth or GitHub App token, revoke the app's authorization in your account settings instead. A revoked or expired token cannot be restored; you have to create a new one.
- Do not wait for GitHub to catch it. If a valid personal access token, OAuth token or GitHub App token is pushed to a public GitHub repository or public gist, GitHub automatically revokes it. GitHub also revokes a personal access token or OAuth token that has not been used in one year (Token expiration and revocation). A token sitting in a published Lovable, Bolt or Vercel frontend is not the same thing as a public GitHub repo or gist. That automatic revocation may never run. Delete the token yourself.
- Review the security log. Check your GitHub security log for unexpected sign-ins, new personal access tokens, new SSH or deploy keys, new repository or webhook activity, and collaborator changes you did not make. Also look at the repositories the leaked token could reach.
- Create a replacement and keep it on the server (next section). GitHub recommends fine-grained tokens, with only the repositories and permissions the job needs, and an expiration for the shortest time you will need it (Keeping your API credentials secure). If you paste the new token into a
VITE_orNEXT_PUBLIC_variable, it will leak the same way. Redeploy after you move the call, then confirm the old token returns 401:curl -s -o /dev/null -w "%{http_code}\n" \ https://api.github.com/user \ -H "Authorization: Bearer OLD_TOKEN"
If the token was also committed to a git repository, deleting it from the latest commit is not enough: it can still sit in history. Rotate it, and use GitHub secret scanning or push protection so it is harder to commit the next one. If other secrets were in the same frontend or the same host incident, rotate those too, in priority order: which keys to rotate, and in what order.
The fix: the browser calls your function, not GitHub
GitHub's guidance is never to hardcode tokens, keys or app secrets in your code, and to store credentials in a secrets manager or an encrypted environment on the server (Keeping your API credentials secure).
- Lovable or Bolt with Supabase: put the call in a Supabase Edge Function and store the token as a secret (Edge Functions → Secrets, or
supabase secrets set GITHUB_TOKEN=…). The function reads it withDeno.env.get("GITHUB_TOKEN"). - Next.js (v0, Cursor): use a Route Handler or Server Action and read
process.env.GITHUB_TOKEN— a variable without theNEXT_PUBLIC_prefix, set in your host's environment settings. - Anything else: a serverless or edge function on your host (Vercel, Netlify, Cloudflare) works the same way.
Then protect that function, or strangers will call it as a free proxy to your GitHub account: require a signed-in user, add a per-user rate limit, and keep the token's permissions and expiry tight. Do not let the browser choose the repository or the action unless your server also checks that the signed-in user is allowed to do it.
What ShipCheck checks (and what it doesn't)
The free scan fetches the raw HTML of your live URL and the same-origin JavaScript files linked from that HTML (and public source maps from those files, when they are available). It does not run JavaScript or click around the app. It flags a GitHub token that matches ghp_, gho_, ghu_, ghs_, ghr_ or github_pat_ in that HTML or those files as a critical finding. A token that only appears in a chunk loaded after you use a feature can be missed, so also use the DevTools and Network checks above. The scan does not call GitHub with the token, and it does not revoke it. It does not probe Storage buckets, and it does not detect Next.js versions. The Supabase table-read test needs a free account that has verified it owns the app; the anonymous scan does not query tables. Paid plans re-scan weekly on Solo ($12/mo) or daily on Builder ($29/mo). Separately, paid plans also check once a day that the app URL returns a status below 400 (a 15 second timeout, with an email after two failed checks). That daily check is not a secrets test.
If you also want to check a public GitHub repository for committed secrets, there is a separate repo scan. It looks at the default branch only, not git history, and it is not a reason to put a token in the frontend.
FAQ
Is a fine-grained GitHub token (github_pat_) safer to put in the frontend?
No. It is still a secret. Fine-grained tokens can be limited to specific repositories and permissions, which reduces the damage after a leak, but they must still live only on the server. GitHub recommends fine-grained tokens over classic ones for the server-side replacement, with the minimum permissions and a short expiry.
Is VITE_GITHUB_TOKEN safe in a Lovable or Bolt app?
No. Vite exposes any VITE_ variable in the client bundle at build time, and Vite's own docs say those variables should not contain API keys. Store GITHUB_TOKEN as a server secret and call GitHub from a Supabase Edge Function or another server function.
Will GitHub automatically revoke a token that leaked in my live app?
Only if a valid personal access token, OAuth token or GitHub App token is pushed to a public GitHub repository or public gist. GitHub also revokes a personal access token or OAuth token that has not been used in one year. A token in a published Lovable, Bolt or Vercel frontend may never be found that way. Delete it yourself in Settings, then create a tightly scoped replacement and keep it on the server.
The app only has a few users, or it is still on a preview URL. Does that matter?
No. Anyone who can load the URL can download the JavaScript and copy the token. The risk is a stranger reading or changing the repositories that token can reach, not your current user count.
Does ShipCheck check for GitHub tokens?
Yes. The free scan searches the live HTML and the same-origin JavaScript linked from that page (plus public source maps it finds) and flags a matching ghp_, github_pat_, gho_, ghu_, ghs_ or ghr_ token as critical. It does not run JavaScript, so also search in DevTools if a feature loads code later. It will not revoke the token for you.
Run the same checks on your app.
A free scan takes under a minute. No card, and no sign-up to see your score and the list of issues.