How to Launch Google Chrome Without CORS Protection on macOS
If you're a developer or testing applications that require disabling CORS (Cross-Origin Resource Sharing), you can easily launch Google Chrome without its CORS protections. This guide will show you how to create a simple command to do this on macOS.
Steps to Launch Chrome Without CORS Protection
1. Close Any Running Instances of Chrome
Before starting, ensure that all instances of Google Chrome are closed.
2. Open Terminal
You can find Terminal in Applications > Utilities > Terminal\
.
3. Create a Shell Script
In the Terminal, create a new shell script by running:
nano ~/chrome-dev
4. Add the Launch Command
In the nano editor, add the following lines:
#!/bin/bash
open -na "Google Chrome" --args --disable-web-security --user-data-dir="/tmp/chrome_dev"
This script opens a new instance of Chrome with CORS disabled.
5. Save and Exit
Press CTRL + X\
, then Y\
, and hit Enter\
to save the file.
6. Make the Script Executable
Run the following command to make your script executable:
chmod +x ~/chrome-dev
7. Add to Your PATH (Optional)
To run the command from anywhere in the terminal, you can add it to your PATH.
Open your profile file:
- For bash users:
nano ~/.bash_profile
- For zsh users:
nano ~/.zshrc
Add the following line to the file:
export PATH="$HOME:$PATH"
Save and exit, then refresh your terminal:
- For bash:
source ~/.bash_profile
- For zsh:
source ~/.zshrc
Using the Command
You can now use the command chrome-dev\
in your terminal to launch Chrome without CORS protection.
Important Reminder
Disabling CORS makes your browser less secure. Use this mode strictly for development and testing purposes, and remember to return to normal browsing afterward.
Conclusion
This simple script can save you time when testing applications that require CORS to be disabled. Just remember to use it responsibly!
Top comments (0)