在Visual Studio代码中启用CORS

在Visual Studio代码中启用CORS,cors,visual-studio-code,Cors,Visual Studio Code,我无法在VisualStudio代码上启动调试器,也无法在chrome上启动CORS扩展,它根本不像我启动时那样出现 在调试时,是否可以指定我希望在Chrome上启用CORS扩展 这是我的launch.json: { "version": "0.2.0", "configurations": [ { "name": "Chrome", "type": "chrome", "request":

我无法在VisualStudio代码上启动调试器,也无法在chrome上启动CORS扩展,它根本不像我启动时那样出现

在调试时,是否可以指定我希望在Chrome上启用CORS扩展

这是我的launch.json:

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

您可以通过使用参数
--disable web security
来指示Chrome实例允许CORS。要从VS代码执行此操作,请使用runtimeArgsconfig选项,即

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