在Visual Studio代码中启用CORS

Mar*_*elo 8 cors visual-studio-code

我无法在Visual Studio Code上启动调试器,也无法在chrome上启动CORS扩展,它只是在我控制纱线启动时不会出现.

在调试时是否可以指定我想在Chrome上启用CORS扩展?

这是我的launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

Ned*_*ley 8

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

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