visual-studio-code - VSC 连接到 SSL LocalHost 以进行角度调试

标签 visual-studio-code vscode-debugger

使用类似的启动配置,我无法从 Angular 11 的 VSC 附加到 httpS://localhost:4200应用程序,既不是 Chrome,也不是 Edge。

启动.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Edge",
            "port": 9222,
            "request": "attach",
            "type": "pwa-msedge",
            "webRoot": "${workspaceFolder}"
        },
        {
            "name": "Attach to pwa-Chrome",
            "port": 9222,
            "request": "attach",
            "type": "pwa-chrome",
            "urlFilter": "https://localhost:4200",
            "webRoot": "${workspaceFolder}"
        },
        {
            "type": "chrome",
            "request": "attach",
            "name": "Attach to Legacy Chrome",
            "port": 9222,
            "urlFilter": "https://localhost:4200",
            "webRoot": "${workspaceFolder}"
        },
        {
            "type": "chrome",
            "request": "launch",
            "name": "F5 against localhost",
            "port": 4201,
            "url": "https://localhost:4200",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

Cannot connect to the target at localhost:9222: Could not connect to debug target at http://localhost:9222: Could not find any debuggable target.

底部启动有效。

最佳答案

如果您没有 SSL 证书(自己的或真实的),ngserve --ssl 即可。

如果仍然不起作用,则使用 diff 端口。这是我的 launch.json:

{
    "name": "UI Chrome",
    "request": "launch",
    "type": "chrome",
    "port": 4201,
    "url": "https://localhost:4200",
    "webRoot": "${workspaceFolder}"
}

更新:为什么是 4201? 4201 是为了帮助我绕过原始调试中的错误,它确实帮助我继续调试。

关于visual-studio-code - VSC 连接到 SSL LocalHost 以进行角度调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68552031/

相关文章:

go - 运行 golang 调试器时,VSCode 调试不在 VARIABLES 区域显示映射值

azure - 如何通过 Azure 静态 Web 应用模拟器 (swa) 使用 Vue.js 应用程序的 VS Code JS 调试器?

go - 调试golang可执行文件时无法在vscode中获取局部变量

python - 可以在脚本中禁用 python breakpoint() (使用 VSCode 调试器)吗?

c++ - C++ 的 VSCode 面包屑导航

c# - Visual Studio Code - 单击类/方法名称 -> 显示定义

javascript - 方法/函数在 IntelliSense 中显示为变量

c# - 运行测试时 VS Code 中没有输出

maven - 如何在 VS Code 中为 Maven 命令创建快捷方式?

ruby-on-rails - 将 ruby​​-debug-ide 附加到现有的 Rails 服务器