【问题标题】:VSCode Chrome Debugger disable web securityVSCode Chrome 调试器禁用网络安全
【发布时间】:2019-05-13 23:55:23
【问题描述】:

我正在开发一个需要在 Chrome 上禁用网络安全的远程应用程序,我有一个 Windows 快捷方式,它采用以下运行时参数:

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" -incognito --disable-web-security --user-data-dir=C:\Program

对于vscode,我有以下launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "web-security-disabled-chrome",
            "url": "http://localhost:8000",
            "runtimeArgs": [
                "--disable-web-security --user-data-dir=C:\\Program",
                "-incognito"
            ], 
            "webRoot": "${workspaceFolder}"
        }
    ]
}

它不会禁用网络安全。

Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID [https://my.remote.ip/restapp/...

我还尝试了以下方法:

给 vscode 一个新的用户数据目录。我看到该文件夹​​已填充,但未禁用网络安全。

将 -user-data-dir 放入它自己的字符串中。 VSCode 显示错误

Cannot connect to runtime process, timeout after 10000ms -(reason: Can't find a valid target taht matches: about:blank. Available pages: ["chrome-ex...://ceimgagkkofjoalgojpkdcmhmbljbbaa/_generated_background_page.html"]).

有谁知道是否可以将 Chrome 调试器配置为运行 web-secruity-disabled?

【问题讨论】:

    标签: google-chrome visual-studio-code


    【解决方案1】:

    您可以尝试使用 chrome 配置文件,如建议的 here

    基本上,(1) 使用配置文件启动 chrome,(2) 接受证书并 (3) 将 vscode 中的 launch.json 更改为如下内容:

    "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}",
      "runtimeArgs": ["--profile-directory=debug-profile"]
    }
    

    这对我有用。

    【讨论】:

      【解决方案2】:

      您的属性中缺少一个破折号,它应该是 --incognito 并且它会起作用。

      "configurations": [
      {
        "type": "chrome",
        "request": "launch",
        "name": "Launch Chrome against localhost",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}",
        "runtimeArgs": ["--incognito"]
      }
      

      【讨论】:

        【解决方案3】:

        这对我有用:

        "runtimeArgs": ["--auto-ssl-client-auth"]
        

        【讨论】:

          【解决方案4】:

          对于证书问题,您应该添加以下命令行参数:

          "configurations": [
          {
            "type": "chrome",
            "request": "launch",
             ...
            "runtimeArgs": ["--ignore-certificate-errors"]
          }
          

          【讨论】:

            猜你喜欢
            • 2021-11-03
            • 1970-01-01
            • 2015-11-07
            • 2019-06-21
            • 2016-01-11
            • 1970-01-01
            • 2016-12-11
            • 2016-06-21
            • 1970-01-01
            相关资源
            最近更新 更多