DEV Community

Benjamin Arambide
Benjamin Arambide

Posted on

How to Launch Google Chrome Without CORS Protection on macOS

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
  • For zsh users:
  nano ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

Add the following line to the file:

export PATH="$HOME:$PATH"
Enter fullscreen mode Exit fullscreen mode

Save and exit, then refresh your terminal:

  • For bash:
  source ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode
  • For zsh:
  source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

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!

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay