Browser
Access to XMLHttpRequest blocked by CORS policy
CORS Policy Blocked
The browser blocked a cross-origin request because the server didn't send appropriate CORS headers.
Common Causes
- Server not sending Access-Control-Allow-Origin
- Preflight (OPTIONS) not handled
- Credentials mode without Allow-Credentials
- Wrong origin in Allow-Origin
Fixes
- 1. Add CORS headers on server
Access-Control-Allow-Origin: https://yourdomain.com Access-Control-Allow-Methods: GET, POST, OPTIONS
- 2. Handle preflight
if (req.method === 'OPTIONS') return res.sendStatus(204);
- 3. Use a proxy in development
// next.config.js: rewrites to backend
Still not fixed?
- • Search the exact error message on Stack Overflow or GitHub Issues
- • Check the official docs for the language or tool
- • Ensure your versions (Node, Python, npm, Docker) are up to date
- • Try in a minimal reproduction (new project, single file)
Related Errors
DuskTools That Might Help
All Errors
JavaScript Heap Out of MemoryModuleNotFoundErrorAddress Already in UseIndentationErrorCannot Find ModulePeer Dependency WarningTypeError: 'NoneType' Not SubscriptableMerge ConflictDocker Port Already AllocatedENOENT: No Such File or DirectoryKeyErrorMaxListenersExceededWarningRecursionErrorDetached HEAD StateEACCES: Permission DeniedValueErrorNo Space Left on DeviceERR_REQUIRE_ESMFileNotFoundError