PROOFFORGE GUIDES
Understand common backend security errors
SHORT ANSWER
Security errors often mean a request does not match the policy you intended. The safe fix is to correct the identity, role, or resource rule—not to turn off access controls until the error disappears.
Last updated
Scan an app you ownStart with the request identity
Check whether the request is anonymous or authenticated, which role reaches the database, and which row or operation is being attempted. A missing session, wrong owner field, or policy for a different command can all produce a denial.
Do not paste an elevated service key into browser code to bypass a denial. Privileged operations belong on a trusted server with their own authentication and authorization checks.
Use a safe test case
Reproduce the behavior with a non-sensitive test record. Test the anonymous role, the intended owner, and a different user; then verify that only the intended cases succeed after the policy change.
Supabase & Postgres
- Fix 'AuthSessionMissingError: Auth session missing!'
Supabase-js was asked for the current user (getUser(), updateUser(), signOut()) but has no session.
- Fix 'Invalid API key' from Supabase
The apikey the request sent doesn't match a live key for that project.
- Fix 'new row violates row-level security policy' (Supabase)
RLS is on for the table, but no INSERT or UPDATE policy's WITH CHECK clause allows the row you sent.
- Fix 'permission denied for table' in Supabase / Postgres
The role making the request (anon, authenticated or service_role) has no privilege on that table.
- Fix PGRST116 'Cannot coerce result to single JSON object'
You asked for exactly one row (.single()), but the query returned zero or more than one, so PostgREST answers 406 with PGRST116.
- Fix 'PGRST301 JWT expired' / PGRST303 in Supabase
The access token sent with the request is past its exp time, so PostgREST rejects it with 401.
- Supabase says your secret key leaked: what to do now
A Supabase secret key (sb_secret_…) was detected in a public GitHub repository through GitHub secret scanning, and Supabase revoked it automatically.
- Fix Supabase Storage upload 'violates row-level security'
Uploads write a row to storage.objects, and RLS there has no INSERT policy allowing this user to write to this bucket and path.
Firebase
- Fix Firestore 'Missing or insufficient permissions'
Cloud Firestore Security Rules denied the read or write (error code permission-denied).
- Fix Firebase Realtime Database 'PERMISSION_DENIED'
Your Realtime Database Security Rules didn't grant .read or .write at that path for this user.
CORS & browser security
- Fix CORS error: wildcard '*' with credentials 'include'
Your request sends cookies or auth (credentials: 'include'), and the server answered Access-Control-Allow-Origin: *, which browsers forbid for credentialed requests.
- Fix CSP warning: 'unsafe-inline' allows unsafe scripts
Your CSP's script-src includes 'unsafe-inline', so any script an attacker injects into the page will run, and the policy no longer stops XSS.
- Fix 'Mixed Content: … was loaded over HTTPS, but requested…'
Your HTTPS page tried to load something over plain http://, such as an API URL, script, iframe or image, and the browser blocked or auto-upgraded it.
- Fix 'No Access-Control-Allow-Origin header is present'
The browser blocked your frontend from reading an API response because the server didn't send Access-Control-Allow-Origin for your site's origin.
- Fix 'Refused to display … in a frame' (X-Frame-Options)
The framed page tells browsers not to be embedded by other sites, via X-Frame-Options or CSP frame-ancestors.
- Fix 'Refused to load the script' (CSP violation)
Your Content-Security-Policy doesn't list the script's origin in script-src (or default-src), so the browser refused to run it.
- 'DevTools failed to load source map': fix or ignore?
A JS or CSS file references a .map file (//# sourceMappingURL=) that DevTools couldn't fetch.
API keys & env vars
- Fix Anthropic 401 authentication_error 'invalid x-api-key'
The Claude API couldn't authenticate the x-api-key header.
- Fix AWS 'SignatureDoesNotMatch' (signature we calculated…)
AWS recomputed the Signature Version 4 signature for your request and got a different value.
- Fix GitHub GH013 'Push cannot contain secrets'
GitHub push protection found a supported secret (an API key or token) in the commits you're pushing and blocked the push.
- Fix Google Maps RefererNotAllowedMapError / ApiTargetBlocked
Your Google Maps API key has restrictions, and this request doesn't match them.
- Fix process.env.NEXT_PUBLIC_… undefined in Next.js
Next.js only sends variables prefixed NEXT_PUBLIC_ to the browser, and it inlines them at build time.
- Fix OpenAI 401 'Incorrect API key provided'
OpenAI didn't accept the key in the Authorization header (401, code invalid_api_key).
- Fix OpenAI 429 'You exceeded your current quota'
A billing error (no credits or a spend limit), not a rate limit. Retrying won't help.
- OpenAI 'your API key was leaked and disabled': what to do
OpenAI found your key somewhere public, usually a GitHub repo or a website's JavaScript, and disabled it immediately.
- Fix Stripe 'Invalid API Key provided' / api_key_expired
The request sent a key Stripe doesn't recognize for that account or mode, often test vs live mixed up, a typo, or an empty env var.
- Fix import.meta.env.VITE_… is undefined (Vite)
Vite only exposes variables that start with VITE_, and it bakes them into the bundle at build time.
HTTPS & certificates
- Fix ERR_SSL_PROTOCOL_ERROR on your custom domain
The TLS handshake failed, usually a certificate not issued yet or DNS pointing elsewhere.
- Fix hstspreload.org errors (max-age, preload, subdomains)
To join the browser HSTS preload list, your HTTPS response must send Strict-Transport-Security with max-age of at least 31536000, plus includeSubDomains and preload.
- Fix NET::ERR_CERT_COMMON_NAME_INVALID
The certificate doesn't cover this hostname, often www vs apex.
Frequently asked questions
Should I disable RLS to fix a denied insert?
No. Add an operation-specific policy that matches the intended user and row owner.
Does an authorization error mean the table is secure?
It confirms one request was denied. Review every operation and role, including reads and updates.
Why does an upsert fail when insert works?
The request may also take an update path, which needs its own policy and row checks.
Last updated November 25, 2026 · Reviewed by ProofForge