Ionic 1.3.x and 308 Url Redirection

Hi,

I have an IOS app built with Ionic 1.3. The app communicates with the backend through .NET Web APIs and the endpoint is hard coded in the app. Everything was working great, until we decided to move the APIs to a sub-domain. A 308 permanent redirect is setup for the API. Now the app doesn’t work completely. In the simulator, I’m getting CORS preflight errors. On the device, no connection at all.

In the app I have white list plugin installed, content security policy and access origin set to *.

How do I resolve this without changing the endpoint in the device and affect end users?

I thought CORS should not affect the app if its running on actual device because its running from file?

Thanks!

Could you show the exact errors ou are getting?

Thanks for your reply! Here is the error from simulator (chrome):

Request URL:http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=https%3A//test.example.com/api/v1/token
Request Method:POST
Status Code:308 Permanent Redirect
Remote Address:[::1]:4400
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Access-Control-Allow-Credentials:true
access-control-allow-headers:*
access-control-allow-methods:HEAD, GET, POST, PUT, DELETE, OPTIONS, TRACE, CONNECT, PATCH
access-control-allow-origin:*
connection:keep-alive
content-length:0
content-type:text/html; charset=UTF-8
date:Thu, 01 Jun 2017 00:03:52 GMT
location:https://apptest.example.com/api/v1/token
server:nginx
X-Powered-By:Express

Request URL:https://apptest.example.com/api/v1/token
Request Method:OPTIONS
Status Code:400 Bad Request
Remote Address:40.126.245.169:443
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Cache-Control:no-cache
Content-Length:77
Content-Type:application/json;charset=UTF-8
Date:Thu, 01 Jun 2017 00:03:52 GMT
Expires:-1
Pragma:no-cache
Set-Cookie:ARRAffinity=e7bb14e8c4b6374c3b0f7124f0b67fbbbec46ea83652796c957ab541ae206b03;Path=/;Domain=apptest.four-walls.com
X-Frame-Options:SAMEORIGIN

Sorry to say, but Ionic 1 is deprecated now. We are at Ionic 3, and I’m expert with Ionic 2. Take advantage of each tech, definitely not ionic 1.

Have fun with Ionic:)

Its 401 unauthorized response and JSON stringify failed. More logs from IOS simulator:

error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures.
2017-06-01 13:40:08.028 app[770:10483] {“data”:{“Message”:“Authorization has been denied for this request.”},“status”:401,“config”:{“method”:“GET”,“transformRequest”:[null],“transformResponse”:[null],“url”:“https://example.com/api",“headers”:{“Authorization”:"Bearer H2-6URUL-gQYtALP9UJZ3QQvq0oTTxwbnTZzULzd6IcIwsEOim2xtSoO3m9DRNj-tJsoq-eYGjMeTe5W8shJNCt5LdOc5fw09VhALUvX9f4RlgP1b3UakiHRLVnXSxGHI6ex3T0wRpwWcefgwMnzzBVV9_Lg3Vm0ITowiPUrVoOsyZeMs_PtdstvdeT-wvV6-hMGRC_WDEUAjbWuvhQyBXk8t7S_gxnmZ4J-mz_6LQYmh3awtxJ5y2G6sp_8e9fOgmMTfdV4_BhqdqjE9FLZvxU9dJ0ygx1FbEDym_MlPSJLkymI0saLTgczvcwghJEUhDA2wnaPbSnNGseegPU8IqjtOI98ltE69x-QBgO8HcJYE_9jZZYdIAhF9TjI6F0-DMkF2oJb4kvTLBZE9JBM04d1snobnZWlRiEU42tSK5Tj2Zot99_mFNBkyYIKhMMMgAAMgbvL7jUjVnLBVBCudYP1VEpJIGxXrPOtLi8yeteGX7cb”,“Accept”:“application/json, text/plain, /”}},“statusText”:“Unauthorized”}