POST请求在Ionic2 App中的IOS上不起作用 [英] POST requests not working on IOS in Ionic2 App

查看:157
本文介绍了POST请求在Ionic2 App中的IOS上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的HTTP请求有问题.在Ionic View,浏览器和Android上一切正常,但在IOS上无法正常工作. GET请求在IOS上也可以正常工作.任何猜测,那会是什么?

I'm having an issue with HTTP requests. Everything is working fine in Ionic View, browser and Android, but not working on IOS. GET requests are working fine on IOS also. Any guesses, what can that be?

我可以为您提供更多信息,只需告诉我您需要什么信息即可.这就是我的package.json中的内容:

I can provide you with more information, just tell me what info do you need. Here's what I have in my package.json:

"dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/cloud-angular": "0.7.0",
    "@ionic/storage": "1.1.7",
    "@types/moment-timezone": "0.2.32",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "moment": "2.15.1",
    "moment-timezone": "0.5.7",
    "ng2-translate": "5.0.0",
    "rxjs": "^5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.0.0",
    "sw-toolbox": "^3.4.0",
    "typescript": "2.0.9"
  },

后端接收发布请求的空白正文.这是我回来的东西:

The backend receives blank body of a post request. Here's what I get back:

ERROR: {"_body":"{\"error\":\"Sign up error\",\"message\":{\"first_name\":[\"First Name cannot be blank.\"],\"last_name\":[\"Last Name cannot be blank.\"],\"email\":[\"Email cannot be blank.\"],\"device_id\":[\"Device Id cannot be blank.\"]}}","status":422,"ok":false,"statusText":"Bad Request","headers":{"Content-Type":["application/json; charset=UTF-8"],"Pragma":["no-cache"]},"type":2,"url":"http://app.EDITED"}

随时问任何问题,谢谢您的帮助!

Feel free to ask anything and thank you for your help!

更新:我们将后端移至HTTPS,现在一切正常:)

UPDATE: We moved our backend to HTTPS and now everything is working fine :)

推荐答案

官方答案似乎在这里:

https://techcrunch.com/2016/06/14/apple-will-require-https-connections-for-ios-apps-by-the-end-of-2016/

Apple只是决定强制使用HTTPS.我怀疑Cordova/Ionic目前根本无法很好地处理此问题(也就是不会引发任何错误,也没有记录在案等等).

Apple simply decided to enforce the use of HTTPS. I suspect Cordova / Ionic are simply not handling this well at the moment (aka no error is thrown, it's not documented etc.)

请记住,Safari检查器将显示数据正在发送到服务器-不正确,所有已发送的数据都已在iOS应用中删除(整个正文)(我输了一天在此).

Keep in mind that the safari inspector will show that data is being sent to the server - that is not correct all data sent is removed (entire body) in the iOS app (I lost a day on this).

如Dmytro Garastovych所述,正确的(也是唯一的)解决方案是迁移到HTTPS

As Dmytro Garastovych mentioned, the correct (and only) solution is to move to HTTPS

这篇关于POST请求在Ionic2 App中的IOS上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆