Title: Making a get request from an iOS app to a MEVN app
Tags: ios;express;vue.js;get;vue-router
Question: I've built a Vuejs SPA with an Express/Node backend. All works fine. I'm now starting to build an iOS app that can use the same Express/Node backend.
From iOS (Xcode), when I make a post request, say to login a user, all works fine. I pass my login credentials using Alamofire and get my JWT token back no sweat.
However, whenever I try to make any get requests (from iOS) to my backend, I get the following response:
<!DOCTYPE html&gt;<html&gt;<head&gt;<meta name=viewport content="width=device-width,initial-scale=1"&gt;<link rel="shortcut icon" type=image/x-icon href=/static/favicon.ico&gt;<link rel=apple-touch-icon href=/static/ios.png&gt;<meta name=apple-mobile-web-app-capable content=yes&gt;<meta name=apple-mobile-web-app-status-bar-style content=white&gt;<script src=https://js.stripe.com/v3/ &gt;</script&gt;<BUNCH OF OTHER STUFF HERE&gt;</body&gt;</html&gt;
The same route works fine in the SPA.
I'm lost. I'm probably making some kind of rookie mistake. If I change the express route to a post route, redeploy, and change the alamofire request to post, it works fine. I'm guessing this has something to do with Vue or Vue Router. If anyone knows a simple fix to allow my get requests to make it through to the backend, I'd be grateful.


Here is another answer: If anyone else runs into this issue...It had to do with the connect-history-api-fallback middleware.
Once I added 'Accept', 'application/json' to the request header, I was good to go.
https://github.com/bripkens/connect-history-api-fallback/blob/master/examples/static-files-and-index-rewrite/assets/js/index.js#L4

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2018:00:01/18/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><express><vue.js><get><vue-router>', 'Title': 'Making a get request from an iOS app to a MEVN app', 'ViewCount': 59, 'id': 48312157, 'user_AboutMe': None, 'user_AccountId': 6817178.0, 'user_DisplayName': 'moz', 'user_Reputation': 1.0, 'user_Views': 0.0, 'user_id': 5245440.0}}