Marcelo
Marcelo

Reputation: 824

Enable CORS at Visual Studio Code

I´m unable to start debugger on Visual Studio Code and also CORS extension on chrome, it simply does not appears as when I console yarn start.

Is it any way to specify that I want CORS extension enabled on Chrome when debugging?

This is my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src"
        }
    ]
}

Upvotes: 19

Views: 31387

Answers (1)

Ned Howley
Ned Howley

Reputation: 858

You can instruct the Chrome instance to allow CORS by starting it with the argument --disable-web-security. To do this from VS Code, use the runtimeArgs config option, i.e.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src",
            "runtimeArgs": ["--disable-web-security"]
        }
    ]
}

Upvotes: 27

Related Questions