我正在设置proxy.conf.json
文件
它适用于离子服务,但在我构建和安装到api调用的设备不起作用时无法使用
{
"/horse": {
"target": "http://100.24.131.250","secure": false,"changeOrigin": true,"logLevel": "debug"
}
}
在设备上运行时,您必须直接传递URL而不是代理服务器
首先检查天气应用是在本地主机还是设备上
isApp()
{
return (!document.URL.startsWith('http')document.URL.startsWith('http://localhost:8080'));
}
然后像这样发布您的基本路径或URL
if(!isApp())
{
this.URL="./horse"
}
else
{
this.URL="www.YourUrl.com"
}