facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.8k stars 26.87k forks source link

BROWSER_ARGS in .env file is not working in Chrome 90 version (MAC OS) #11917

Open Karthick-FK opened 2 years ago

Karthick-FK commented 2 years ago

I have tried the below method to start app in a web security disabled browser to avoid CORS issue. (Added in .env file)

BROWSER=google chrome BROWSER_ARGS=--user-data-dir=/tmp/temporary-chrome-profile-dir --disable-web-security --disable-site-isolation-trials --ignore-certificate-errors --disable-features=SameSiteByDefaultCookies,CookiesWithoutSameSiteMustBeSecure --unsafely-treat-insecure-origin-as-secure=http://localhost:3000

When we do this in terminal (open chrome command with above args) - It is launching the browser with given browser args. But, BROWSERARGS is getting ignored if we provide inside .env_ file. It is launching in the normal chrome browser (wit security enabled)

Please update me if you need further details from my end.

stacy-rendall commented 2 years ago

I can confirm that BROWSER is also not working when placed in an .env file with react-scripts@5 (I'm using .env.local in this case), i.e. BROWSER=msedge used to work with react-scripts@4, now the default browser opens

Karthick-FK commented 2 years ago

@stacy-rendall Am using "react-scripts": "3.4.1" in my package.json file

arvigeus commented 2 years ago

I can confirm that BROWSER is also not working when placed in an .env

I noticed that too, but I thought I botched my recent system reinstall and was doing something wrong.

I believe the BROWSER_ARGS issue is somewhere around here /packages/react-dev-utils/openBrowser.js:#L77-L107, likely line 96 has to be changed to chromiumBrowser + " " + args. Since I don't have a Mac, I cannot confirm the solution.

FloydJohn commented 2 years ago

Hi @Karthick-FK, could you try to create a new project using the CRA version of the PR linked above? It should solve both the BROWSER and BROWSER_ARGS issue.

I tested the browser opening on Linux, testing on a Mac would be nice. Thanks!