Project Description: using Vue framework, AJAX request using Axios, the back-end has set CORS
In the case of cross domain, there is no problem in the PC browser access, you can get data normally
The HTTP status code returned by the browser on the mobile phone is 0, so the data cannot be obtained, as shown in the figure
First of all, in order to prove that it is caused by cross domain problems, I made a homologous request on my own server. There is no problem on the mobile terminal, and the data can be obtained normally. This can prove that it is caused by cross domain problems
At the same time, in order to prove that it is Axios related, I use native Ajax and jQuery for cross domain requests respectively, and there is no problem on the mobile side.
It can be summarized as follows: in the case of cross domain, Axios has problems in the mobile request
So I think of two ways to deal with it: the first is not to make cross domain requests, but this is limited to the back-end, because the web page is stored in the back-end server, and the domain name of the general API is a secondary domain name, so the secondary domain name is also a cross domain request, so this method is abandoned. The second is to use the native Ajax request or jQuery instead of the Axios request If so, there will be a lot less functions.
I would like to ask why this situation occurs on the mobile end when cross domain requests are made with Axios! Thank you for your answers.
Supplementary note: the built-in QQ browser and mobile chrome in wechat can request normally, but the request fails in UC and QQ browser alone