CORS Issues
Understanding and troubleshooting CORS with Static Forms
CORS (Cross-Origin Resource Sharing) is a browser security feature that controls which domains can make requests to your API. Static Forms supports CORS by default, allowing requests from any domain.
What is CORS?
CORS is a security mechanism that browsers use to restrict cross-origin HTTP requests. When your website (e.g., https://yoursite.com) makes a request to Static Forms API (https://api.staticforms.dev), the browser checks CORS headers to ensure the request is allowed.
Static Forms CORS Support
Static Forms API supports CORS by default:
- All origins are allowed for form submissions
- No additional configuration required
- Works with AJAX/fetch requests
- Supports all HTTP methods (POST, OPTIONS, etc.)
No CORS Configuration Needed
You don't need to configure anything for CORS. Static Forms accepts requests from any domain by default.
Common CORS Errors
If you see CORS errors, here's what they mean:
Error: "Access to fetch blocked by CORS policy"
This error typically means:
- The request is being blocked by browser security
- You're using the wrong URL
- There's a network/proxy issue
Troubleshooting Steps
If you encounter CORS errors:
Verify the URL
Ensure you're using the correct endpoint: https://api.staticforms.dev/submit
Check Request Method
Verify you're using POST method (not GET).
Inspect Network Tab
Open browser DevTools → Network tab and check:
- If the request is being made
- What the actual error response is
- Response headers
Check Browser Console
Look for the full error message in the browser console for more details.
AJAX/Fetch Requests
When making AJAX requests, ensure proper headers:
Preflight Requests
Browsers may send a preflight OPTIONS request before the actual POST request. Static Forms handles this automatically:
- OPTIONS requests are automatically handled
- Proper CORS headers are returned
- No action required on your part
Testing CORS
To test if CORS is working:
Common Issues
CORS Error in Development
If testing on localhost, ensure you're using http://localhost (not file://). CORS doesn't apply to same-origin requests.
Proxy or CDN Issues
Some proxies or CDNs may interfere with CORS headers. Check if your hosting provider modifies CORS headers.
Browser Extensions
Some browser extensions (ad blockers, privacy tools) may interfere with CORS. Try disabling extensions or using incognito mode.
Still Having Issues?
If you're still experiencing CORS errors, check the Troubleshooting guide or contact support.