Yet another CORS question.
I have picked up an ionic v1 app that hasnt been touched in a few years to make small changes, after the pain of getting the environment setup and the thing building I’m having a problem with all POST requests.
- This solved the issue in ios - https://github.com/Raphcal/cordova-plugin-cors
- Of course running chrome with disable web security fixed it with the browser
- Android wouldnt work nomatter what
When investigating I noticed the apache server had this set in its configuration:
Header always set Access-Control-Allow-Origin "http://localhost:8080"
However in the access log the origin has a different port:
194.x.x.x- - [24/Nov/2020:22:53:11 +0000] "POST /l HTTP/1.1" 200 260 "[http://localhost:8100/"](http://localhost:8100/%22) "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
I noticed in production logs the old version app is actually using/sending :8080 so the existing header would’ve worked for it. Adding this allowed the requests to work:
Header always set Access-Control-Allow-Origin "http://localhost:8100"
My questions around the port number - where is set? Did the number change at some point with different versions of ionic? Is it consistent or do I need to use a wildcard in apache?