gpt4 book ai didi

angular - 在 ng 服务器中使用等效的 proxy-config 选项来运行 ng e2e

转载 作者:行者123 更新时间:2023-12-04 16:05:53 24 4
gpt4 key购买 nike

我正在使用其他文章中描述的代理配置将我的 Angular 应用程序中的调用重定向到我的后端 API。我使用以下内容作为我的 proxy.conf.json 文件:-

{
"/comparison/api": {
"target": "http://localhost:8080",
"secure": false,
"changeOrigin": true
}
}

这很好用,将 API 调用重定向到我的 Node/Express stub API 服务。

当我开始使用 Angular CLI 运行 E2E 测试时,没有 --proxy-config 选项。有谁知道我如何在 E2E Protractor 测试中设置相同的代理重定向?

最佳答案

目前 e2e 不支持 --proxy-config 作为选项。它是很高兴拥有列表的一部分。引用 - https://github.com/angular/angular-cli/issues/6358

这是目前的解决方法。

e2e 在后面使用 ng serveng serve 可以配置为使用代理。

修改angular.json文件中的serve选项,添加proxyConfig

"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "ChangeManagementPortal:build",
"proxyConfig": "proxy.conf.json"
}

现在 ng e2e 将使用代理重定向运行。

关于angular - 在 ng 服务器中使用等效的 proxy-config 选项来运行 ng e2e,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49329191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com