在Visual Studio代码中启用CORS

问题描述 投票:5回答:1

我无法在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"
        }
    ]
}
cors visual-studio-code
1个回答
6
投票

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

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src",
            "runtimeArgs": ["--disable-web-security"]
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.