What is CORS?
CORS is a security feature implemented by web browsers that controls whether a web page can make requests to a different domain than the one that served the page.The same-origin policy
By default, browsers enforce the same-origin policy, which prevents JavaScript running onhttps://yourapp.com from making requests to https://api.example.com. This protects users from malicious scripts.
How CORS works
When you make a cross-origin request, the browser:- Sends a preflight request (OPTIONS) to the API server
- Checks if the server allows requests from your origin
- If allowed, makes the actual request
- If denied, blocks the request and shows a CORS error
CORS values in the directory
Each API listing shows one of three CORS values:Yes - CORS enabled
The API supports cross-origin requests and can be called directly from browser-based applications. Examples:- Dogs (Animals category) - Random dog pictures
- CoinGecko (Cryptocurrency) - Crypto prices and data
- Agify.io (Development) - Age estimation from names
- Genderize.io (Development) - Gender estimation from names
- Studio Ghibli (Anime) - Studio Ghibli film data
- Dog Facts (Animals) - Random dog facts
- HTTP Cat (Animals) - HTTP status code cats
- Art Institute of Chicago (Art & Design) - Museum art data
No - CORS not enabled
The API does not support CORS. These APIs can only be called from server-side code. Examples:- Cats (Animals) - Pictures of cats from Tumblr
- Cat Facts (Animals) - Daily cat facts
- Axolotl (Animals) - Axolotl pictures and facts
- RandomDuck (Animals) - Random duck pictures
- RandomFox (Animals) - Random fox pictures
- Waifu.pics (Anime) - Anime image sharing
- Metropolitan Museum of Art (Art & Design) - Met Museum data
Unknown - CORS status unclear
CORS support has not been verified. Test the API to confirm compatibility with your use case. Examples:- eBird (Animals) - Birding observations
- RescueGroups (Animals) - Pet adoption data
- xeno-canto (Animals) - Bird recordings
- AniDB (Anime) - Anime database
- AniList (Anime) - Anime discovery and tracking
When CORS matters
- Client-side (CORS required)
- Server-side (CORS not required)
Browser-based applications
You need CORS support if you’re building:- Single-page applications (React, Vue, Angular)
- Static sites with JavaScript (vanilla JS, jQuery)
- Browser extensions
- Progressive web apps (PWAs)
- Any code running in a web browser
Example scenario
- Request succeeds
- Data is returned
- Everything works
- Browser blocks the request
- Console shows CORS error
- Request never reaches the server
- You cannot access the data
Typical CORS error
Working without CORS
If you need to use an API that doesn’t support CORS in a browser application, you have several options:1. Use a backend proxy (recommended)
Create an endpoint on your server that calls the API:2. Use a CORS proxy service
Warning: Only use for development/testing, not production.- Third-party can see all your requests
- May log sensitive data
- Can go offline at any time
- May have rate limits
- Security and privacy concerns
3. Choose an alternative API
If you’re building a client-side app, prioritize APIs with CORS: Yes to avoid these workarounds.CORS configuration note
From the CONTRIBUTING.md documentation:Without proper CORS configuration an API will only be usable server side.This is a critical consideration when choosing an API. If you’re building:
- Client-side app → Filter for CORS: Yes
- Server-side app → Any CORS value works
- Full-stack app → Backend can call any API, frontend needs CORS
Testing CORS support
You can test if an API supports CORS:Method 1: Browser console
Method 2: Check response headers
Use browser DevTools Network tab:- Make a request to the API
- Check Response Headers
- Look for
Access-Control-Allow-Origin
Method 3: Command line
Common CORS patterns
Public data APIs
APIs serving public data often enable CORS:- Yes CORS: Dog pictures, weather data, public facts
- Designed for browser consumption
- No authentication needed
- Broad
Access-Control-Allow-Origin: *
Authenticated APIs
APIs requiring API keys may:- Enable CORS with restrictions
- Require specific origins to be whitelisted
- Support CORS only on certain endpoints
- Disable CORS for security (server-side only)
Enterprise APIs
Business/enterprise APIs often:- Disable CORS (CORS: No)
- Intended for server-to-server communication
- Require authenticated backend calls
- More control over access
Security considerations
CORS is not authentication
CORS controls where requests come from, not who makes them:- CORS doesn’t protect your API key
- Anyone can view frontend code and extract keys
- Use server-side code for sensitive operations
- CORS is about browser security, not API security
API keys in browsers
When using APIs with CORS in browsers:- Use APIs with no auth for public data
- Keep sensitive API keys on your server
- Use environment variables
- Implement rate limiting on your backend
- Consider API key rotation
Quick reference
| Scenario | CORS needed? | Recommended approach |
|---|---|---|
| React/Vue/Angular app calling API | Yes | Use API with CORS: Yes or add backend proxy |
| Node.js backend calling API | No | Call any API directly |
| Static HTML + JavaScript | Yes | Use API with CORS: Yes |
| Mobile app (React Native) | No | Call any API directly |
| Browser extension | Yes | Use API with CORS: Yes or background script |
| Serverless function (Lambda) | No | Call any API directly |
Next steps
- Learn about authentication types
- Discover how to search and filter APIs
- Browse all available APIs
