如果你在创建的代理上无法运行Angular,并且它将默认的localhost放在你的API之前,你可以尝试以下解决方法:
{
"/api/*": {
"target": "http://localhost:3000",
"secure": false,
"logLevel": "debug"
}
}
在这个配置文件中,你需要更改target值为你实际的API地址。这里的示例将请求路径以/api/开头的请求代理到http://localhost:3000上。
"scripts": {
"start": "ng serve --proxy-config proxy.conf.json"
}
确保你运行Angular应用程序时使用了这个命令。
选择清除缓存和Cookie选项,然后重新加载应用程序。
这些解决方法应该能够帮助你解决Angular无法在你创建的代理上运行,并在API之前放置了默认的localhost的问题。