Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
        }
    ]
}
like image 656
Marcelo Avatar asked May 10 '18 15:05

Marcelo


People also ask

How do I enable CORS browser?

Simply activate the add-on and perform the request. CORS or Cross-Origin Resource Sharing is blocked in modern browsers by default (in JavaScript APIs). Installing this add-on will allow you to unblock this feature.

How do I fix cross-origin request blocked?

To get rid of a CORS error, you can download a browser extension like CORS Unblock ↗. The extension appends Access-Control-Allow-Origin: * to every HTTP response when it is enabled. It can also add custom Access-Control-Allow-Origin and Access-Control-Allow-Methods headers to the responses.


1 Answers

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"]
        }
    ]
}
like image 99
Ned Howley Avatar answered Sep 20 '22 17:09

Ned Howley