Skip to content
AI-powered appsNewChat, vision, voice, generationBookings & schedulingAppointments that book themselvesShops & sellingA storefront in every pocketClient & businessRun the operation from one placeCommunities & clubsA home that is not a group chat
Health & wellnessHabits, tracking and calmGames2D, 3D and multiplayerPersonal & toolsThe tool you wish existedInternal toolsThe tool ops never had time for
See all use cases
ArcadeNewPricingSecurity
EngineThe game engine and World EditorHow it worksFrom one sentence to a live productDocsGuides for building and publishingBlogStories, guides and newsChangelogWhat shipped latelyStatusUptime of every serviceSupportGet help from the team
AI-powered appsBookings & schedulingShops & sellingClient & businessCommunities & clubsHealth & wellnessGamesPersonal & toolsInternal tools
See all use cases
ArcadeNewPricingSecurity
EngineHow it worksDocsBlogChangelogStatusSupport
Language
Blog
TroubleshootingNovember 22, 20265 min read

CORS errors explained and fixed

A CORS error means the server you called did not say your website is allowed to read its answer. The fix lives on that server, or in a server function you control.

Startbase Team
Editorial ink illustration of a border checkpoint with a lowered barrier arm and a waiting parcel, the guard's stamp in ember orange

Key takeaways

  • CORS errors are enforced by the browser but fixed on the server. Nothing in your frontend code can switch the check off.
  • If you call a third-party API straight from the browser and it does not allow it, move the call into a server function.
  • A server error without CORS headers often shows up as a CORS error. Check the server logs before chasing headers.

A CORS error ("has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present") means your web page asked a server on a different address for data, and that server's reply did not say your page is allowed to read it. The browser received the answer and then threw it away to protect the user. The most likely cause is that you are calling a third-party API directly from the browser, or calling your own server function that does not send the right headers. Either way, the fix is on the server side, never in the page.

What CORS actually checks

Browsers follow a rule called the same-origin policy: a page at `https://shop.example.com` can freely read responses from `https://shop.example.com`, but not from `https://api.other.com`, unless that other server opts in. An origin is the combination of scheme, host and port, so `http` vs `https`, `www` vs no `www`, and port 5173 vs 443 all count as different origins.

CORS (cross-origin resource sharing) is how a server opts in. It adds response headers like `Access-Control-Allow-Origin: https://shop.example.com`. The browser sees the header, checks it matches the page, and hands the data to your code. No header, or the wrong one, and your code gets an error instead. Our glossary has a shorter definition of CORS if you want only the concept.

For anything beyond a simple GET (a POST with JSON, a request with an Authorization header), the browser first sends a preflight: an `OPTIONS` request asking "may I?". The server must answer that with the allow headers too, plus which methods and headers it accepts. Many CORS bugs are really preflight bugs.

Why it works in Postman but not in your app

CORS is a browser rule. Command-line tools, server code and API testers do not enforce it, which is why the same request succeeds there. That is also why it is not a security feature for the server: it protects users' browsers from pages reading data they should not. It does not stop anyone from calling the API from elsewhere.

The five usual causes, most likely first

1. Calling a third-party API straight from the browser

Plenty of APIs (payment providers, many AI and data APIs, most "secret key" APIs) deliberately do not allow browser calls, because doing so would mean putting the secret key in your page where anyone can read it. How to check: the failing URL belongs to someone else's domain, and the API's documentation says to call it from a server. The fix: move the call into a server function. In Startbase Cloud that means an edge function: it holds the key in Backend → Secrets, calls the API server-to-server (no CORS involved), and returns only what your page needs. This is the right fix, not a workaround, and it closes a key leak at the same time. More in edge functions explained.

2. Your own function does not answer the preflight

An edge function that handles POST but not OPTIONS fails every cross-origin call before your code runs. How to check: in the Network tab, look for an `OPTIONS` request to the function that returns 404, 405 or 500, followed by no actual POST. The fix: the function should return early for `OPTIONS` with status 200 or 204 and the CORS headers, and add the same headers to every other response:

  • `Access-Control-Allow-Origin`: your site's origin (or `*` for truly public, keyless data).
  • `Access-Control-Allow-Headers`: at least the headers you send, typically `authorization, content-type`, plus `apikey` and `x-client-info` for Supabase clients.
  • `Access-Control-Allow-Methods`: for example `GET, POST, OPTIONS`.

3. A server error dressed up as a CORS error

This one wastes the most time. Your function crashes, the platform returns a plain 500 page without your CORS headers, and the browser reports "blocked by CORS policy" instead of the crash. How to check: the Network tab shows a status of 500 or 502 alongside the CORS message. Open Backend → Logs, pick the Functions source and look at the same minute; the real error (often a missing secret or a typo) is there. The fix: fix the crash, and make sure error responses carry the CORS headers too, so the next failure reports honestly. Each expanded log row has a Fix with AI button that sends the event to the agent.

4. The allowed origin does not match your new address

If CORS worked in the preview and breaks after publishing or adding a custom domain, the server probably allows a specific list of origins and your new one is not on it. `https://www.yourapp.com` and `https://yourapp.com` are different. How to check: compare the `Origin` request header with the response's `Access-Control-Allow-Origin`. The fix: add every live origin to the list, or echo back the request origin when it appears in an allow list you keep in one place.

5. Credentials with a wildcard

If your request sends cookies (`credentials: 'include'`), browsers refuse `Access-Control-Allow-Origin: *`. The server must name the exact origin and also send `Access-Control-Allow-Credentials: true`. How to check: the console message mentions "credentials mode is include". The fix: name the origin explicitly, or switch to a bearer token in the Authorization header, which most Supabase-style apps already use.

Fixes that look tempting and backfire

  • A browser extension that disables CORS. It hides the error on your machine only. Every visitor still hits it.
  • `mode: 'no-cors'` in fetch. The request goes out, but the response becomes unreadable to your code. You trade an error for silent empty data.
  • A free public CORS proxy. Your requests (and any keys in them) pass through a stranger's server, which can log them, rate-limit you or vanish.
  • **`Access-Control-Allow-Origin: *` on an endpoint that uses cookies or returns private data.** It either does not work (with credentials) or invites any site to read responses meant for your users.

The message to send the agent

Give the agent the failing URL, the method and what the Network tab shows for both requests. It can read function logs and rewrite the function:

The checkout button fails in the browser with "blocked by CORS policy: Response to preflight request doesn't pass access control check". The request is a POST from https://www.example.com to our create-checkout edge function. The OPTIONS request returns 500. Please check the function logs for that time, fix the crash, make the function answer OPTIONS with the CORS headers, include the same headers on success and error responses, and allow both https://example.com and https://www.example.com plus the startbase.app address. Do not use a public CORS proxy or put any secret in the frontend.

If the underlying need is calling an outside service, see what an API is and API keys and secrets for where each piece should live.

Frequently asked questions

Can I fix a CORS error in my frontend code?

No. The browser enforces CORS based on the server's response headers. You either change the server to send the right headers, or call the API from your own server function, which is not subject to CORS.

Why do I get a CORS error only when the request fails?

Many servers add CORS headers only to successful responses. When they crash, the error page lacks the headers, and the browser reports CORS instead of the real error. Check the server logs.

Is it safe to allow all origins with *?

For public data that needs no login and no keys, yes. For anything tied to a user's session or private data, name the allowed origins instead.

Does CORS protect my API from abuse?

No. It only stops other websites from reading responses inside a visitor's browser. Scripts and servers ignore it. Protect APIs with authentication, access rules and rate limits.

On this page

  • What CORS actually checks
  • Why it works in Postman but not in your app
  • The five usual causes, most likely first
  • Fixes that look tempting and backfire
  • The message to send the agent

Keep reading

More in Troubleshooting
Editorial ink illustration of an overstuffed card catalog drawer spilling index cards, the brass tab of one card in ember orange
TroubleshootingNovember 22, 2026

Why is my app slow with lots of data?

An app that slows down as data grows almost always loads or draws too much at once. Here is how to find which part is slow and the fix for each.

6 min read
Editorial ink illustration of a brass street sign on a lamppost with a blank second sign being fitted, the bolt in ember orange
TroubleshootingNovember 22, 2026

Custom domain not working: a checklist

A custom domain fails for a short list of reasons: the record is wrong, it has not propagated, an old record conflicts, or you connected the root domain where only www works.

5 min read

Read less. Ship more.

Everything in this post is one prompt away. Describe your app and watch it build.

Start building

Apps, games, backends and publishing from one conversation.

Product

  • Features
  • Use cases
  • Pricing
  • Changelog

Resources

  • Blog
  • Docs
  • Support
  • Status
  • Security

Contact

  • w@startbase.ai
  • X / Twitter
  • LinkedIn
  • Instagram

Legal

  • Terms
  • Privacy

© 2026 Startbase. All rights reserved.