Know what CORS does
Cross-origin resource sharing (CORS) tells a browser which websites may read certain responses. It does not stop a direct client from contacting an API and does not prove a user is authorised.
Authentication and access control must remain on the server. A permissive CORS rule can expose responses to an untrusted site when a browser also sends credentials.
Use a specific origin allowlist
List the trusted front-end origins. Match the scheme, host and port as required. Do not reflect any Origin value without checking it against the allowlist.
Avoid wildcard origins for private data. Do not combine wildcard access with credentials. Review development and preview domains before allowing them to access production data.
Test preflight and error responses
Check allowed methods and headers. Confirm that error responses do not expose sensitive data to untrusted origins.
Review CORS after domain changes and product launches. A web application assessment can include browser-to-API access rules in its scope.
