enable CORS support in Chrome on Mac
Background
CORS (Cross-Origin Resource Sharing) is a security feature implemented in modern web browsers. It restricts web pages from making requests to a domain different from the one that served the original page. This mechanism protects users from malicious scripts attempting to access sensitive information across sites.
However, during local development or API testing, CORS can sometimes block legitimate requests. In such cases, it may be helpful to temporarily disable CORS restrictions for development purposes.
⚠️ Warning: Disabling web security significantly reduces browser protections. Use this method strictly for development. Do not browse the internet with this instance.
Solution: Launch Chrome with CORS Disabled on macOS
To start a new Chrome instance with web security disabled, run the following command in your terminal:
1 |
|
Explanation:
open -n: Opens a new Chrome instance, even if another one is running.
–disable-web-security: Disables CORS and other security features.
–user-data-dir: Specifies a separate user profile directory to isolate this instance from your main Chrome profile.