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
GlossaryNovember 22, 20263 min read

What is CORS?

The red "blocked by CORS policy" line in your console is not your frontend's fault and not a bug in the browser. It is the server not yet saying your site is allowed in.

Startbase Team
Editorial ink illustration of a building mail slot with a guest list pinned beside it, the guest list in ember orange

Key takeaways

  • Browsers block scripts from reading responses from another origin unless that server answers with permission headers.
  • CORS is fixed on the server you are calling, never in the frontend; a wildcard origin is risky for anything with user data.
  • CORS only applies in browsers. Server code and mobile apps are not subject to it, so it does not protect an API on its own.

Behind the acronym, CORS (Cross-Origin Resource Sharing) is a browser security rule: a page loaded from one website can only read responses from a different website if that other site explicitly allows it, by sending back headers such as `Access-Control-Allow-Origin`. When you see "has been blocked by CORS policy" in the browser console, the server you called did not grant that permission.

An everyday example: the doorman's guest list

Picture an apartment building with a doorman. Anyone can walk up and ask for a package to be delivered to a resident. But the doorman only hands a reply back to visitors on the resident's guest list. Your browser is the doorman. A script from `myshop.startbase.app` asks `api.example.com` for data. The request goes out, but unless the response says "myshop.startbase.app is on my list," the browser refuses to hand the answer to the script.

An origin is the scheme, domain and port together. `https://myshop.com` and `https://www.myshop.com` are different origins, and so are `http://localhost:3000` and `http://localhost:5173`. That surprises people more than anything else about CORS.

The preflight request

For requests that could change data (a POST with JSON, a PUT or DELETE, or anything carrying an `Authorization` header), the browser first sends an automatic OPTIONS request asking "may I?" The server must answer with which origins, methods and headers it accepts. If the function you wrote only handles POST and returns an error for OPTIONS, every real request fails before it starts, even though the POST code itself is fine.

The right fix (and the wrong ones)

  • Right: have the server you are calling return `Access-Control-Allow-Origin` with your exact site addresses, answer OPTIONS requests, and list the headers your app sends.
  • Risky: `Access-Control-Allow-Origin: *` lets any website's scripts read the response. Acceptable for truly public data, a bad idea for anything tied to a signed-in user.
  • Wrong: browser extensions that disable CORS. They make it work on your machine and nowhere else.
  • When you do not control the server: call the third-party API from your own backend function instead of from the browser. That also keeps its key out of the frontend.

Why it matters when building with Startbase

A published Startbase app lives at one address (a `*.startbase.app` address or your custom domain) while its backend functions live at another, so calls from the browser to an edge function are cross-origin. The agent writes those functions and checks its work, but CORS errors still turn up when an address changes, for example after you connect a custom domain and the function only allows the old one. The fastest fix is to give the agent the exact console line.

After connecting my custom domain, the browser console shows: "Access to fetch at the send-invite function from origin https://www.myclub.com has been blocked by CORS policy." Allow my published address, my custom domain and the preview origin in that function, answer OPTIONS preflight requests, and do not use a wildcard origin.

For more on reading console errors, see how to fix bugs with AI.

Common confusions

  • CORS does not secure your API. It only stops other websites' scripts from reading responses in a browser. A script on a server, or curl, ignores it entirely. Real protection is authentication and authorization.
  • The request often still reached the server. A blocked simple request may have run; the browser just hid the answer. Do not assume nothing happened.
  • Mobile apps do not hit CORS because there is no browser enforcing it, which is why the same call can work in Expo Go and fail on the web version.

Frequently asked questions

Why does my API work in Postman but not in my app?

Postman is not a browser, so it does not enforce CORS. The browser does, and it needs the server to send the right Access-Control headers for your site's origin.

Can I fix a CORS error in my frontend code?

No. The permission has to come from the server being called. From the frontend, the only workaround is routing the call through a backend you control.

On this page

  • An everyday example: the doorman's guest list
  • The preflight request
  • The right fix (and the wrong ones)
  • Why it matters when building with Startbase
  • Common confusions

Keep reading

More in Glossary
Editorial ink illustration of a hand-cranked music box drum plucking a metal comb, the crank handle in ember orange
GlossaryNovember 22, 2026

What is a game loop?

Every real-time game runs one repeating cycle: read input, update the world, draw it. Here is what that cycle looks like and why it decides how your game feels.

3 min read
Editorial ink illustration of a brass stopwatch beside a small wind-up toy car, the second hand in ember orange
GlossaryNovember 22, 2026

What is delta time?

Delta time is the number that keeps your game the same speed on every screen. Here is how to use it, where it breaks, and how to spot a game that forgot it.

3 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.