How to add missing referrer header to Cordova IOS App

那年仲夏 提交于 2019-12-01 13:04:46

问题


I am using Cordova to build an iOS App. I use the Ionic engine meaning that the app is served from a webserver running on the device.

My window.location.origin is "ionic://my-app.com".

A third party API (that I need to use in order to fetch an address suggestion based on what the user types) rejects my HTTP requests because the referrer header is missing in the request.

It's not possible to programmatically add a referrer from the JS layer and these did not work:

  • <meta name="referrer" content="origin">

  • <meta name="referrer" content="always">

I suspect that the issue is that the API is using https and my iOS App is using a custom scheme (the default one is ionic:// and cannot be changed to https). For this reason the referrer header is not added by the WebView.

How can I solve this issue?


回答1:


I'd try following the CORS workaround for native apps that uses the HTTP plugin from ionic. See here for more details: https://ionicframework.com/docs/faq/cors#1-native-only-apps-ios-android-



来源:https://stackoverflow.com/questions/56044902/how-to-add-missing-referrer-header-to-cordova-ios-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!