Open alanhe421 opened 7 years ago
请求wakatime-api存在跨域问题,如果是真机运行,通过cordova-plugin-whitelist设定,即可解决, ionic serve浏览调试的话,通过在ionic.config.json进行如下设定
ionic.config.json
{ "name": "cutePuppyPics", "app_id": "", "v2": true, "typescript": true, "proxies": [ { "path": "/api/v1", "proxyUrl": "https://wakatime.com/api/v1" } ] }
但问题就是,如果配置文件进行代理设定的话,APIService里的请求路径就是/api/v1,但真机打包却需要绝对的,很不方便,需要通过打包,自动替换路径为好。
放弃通过ionic.config.json文件设定代理方式,这种方式,真机不能够解决问题。所以直接通过安装谷歌插件扩展程序Allow-Control-Allow-Origin: *,解决浏览器调试出现的跨域问题即可,真机调试,只需要在config.xml文件添加白名单配置项即可
<allow-navigation href="https://wakatime.com/api/*"/>
请求wakatime-api存在跨域问题,如果是真机运行,通过cordova-plugin-whitelist设定,即可解决, ionic serve浏览调试的话,通过在
ionic.config.json
进行如下设定但问题就是,如果配置文件进行代理设定的话,APIService里的请求路径就是/api/v1,但真机打包却需要绝对的,很不方便,需要通过打包,自动替换路径为好。