Hi, I’ve got a very basic auth service in Angular that posts to an ExpressJS endpoint. When I run the ionic app in Chrome with --disable-web-security
it works just fine. It posts as expected and the correct response is received.
Here’s a look at the request sent from Angular – dumped from an Angular interceptor
{
"method": "POST",
"transformRequest": [
null
],
"transformResponse": [
null
],
"data": {
"email": "redacted",
"password": "redacted"
},
"url": "http://localhost:3000/api/session",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=utf-8"
}
}
…and on the server, I get this:
POST /api/session 200 50.524 ms - 2460
When I run the app as:
$ ionic emulate ios -l -c -s
this is what is posted – again logged from Angular interceptor:
13 099862 log {
"method": "POST",
"transformRequest": [
null
],
"transformResponse": [
null
],
"data": {
"email": "redacted",
"password": "redacted"
},
"url": "http://localhost:3000/api/session",
"headers": {
"Accept": "application/json, text/plain, */*",
"Content-Type": "application/json;charset=utf-8"
}
}
and this is what is received by the server: OPTIONS /api/session 200 2.044 ms - 11
So, the tl;dr is:
- When I run the ionic app in the browser and
POST
it works just fine - When I run the ionic app in the iOS emulator – same code, same server, same environment, the http
POST
is changed to httpOPTIONS
somewhere in the outbound chain (which fails, obviously).
Any clue what’s going on here? I haven’t done a ton of iOS dev. so I’m wondering if there is some bizarre CORS setting I need to tweak?