Capacitor: ^6.1.2
Frontend: React 18
Backend: Ruby on rails
Frontend network requests: Axios (1.11.0)
Hey all, my Capacitor app has started giving me an Axios Network error all of a sudden, which I have added below. It was working perfectly fine on HTTP and HTTPS (hosted) endpoints on a simulator and a physical device, but then it started giving me the Network error. It seems like this happens with GET requests with parameters, because I made a POST request with a request body and that was fine.
I made the same API request, that gave the Network Error, in the simulator browser and the response was correctly displayed.
The backend CORS is setup to handle requests from Capacitor. Nothing was changed in the CORS file too. For the same api call that shows a Network Error on the front end, the backend accepts that request and returns a 200.
The only thing i can think of was a recent update of Axios from ^1.7.5 to ^1.11.0. Reverting to that version does not fix it.
Any help on this would mean a lot!
{
"message": "Network Error",
"name": "AxiosError",
"stack": "handleError@http://192.168.0.248:3000/node_modules/.vite/deps/axios.js:1615:36\n@http://192.168.0.248:3000/node_modules/.vite/deps/axios.js:2143:58",
"config": {
"transitional": {
"silentJSONParsing": true,
"forcedJSONParsing": true,
"clarifyTimeoutError": false
},
"adapter": [
"xhr",
"http",
"fetch"
],
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1,
"env": {},
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
},
"baseURL": "http://localhost:3001",
"params": {
"query": "New",
"fe_version": "new"
},
"signal": {},
"method": "get",
"url": "http://localhost:3001/api/v1/endpoint",
"allowAbsoluteUrls": true
},
"code": "ERR_NETWORK"
}
```*emphasized text*