I am trying to test out my MERN app with Next.js on my mobile using my local IP address. Everything works fine on localhost, but when I try perform any action on the app that requires a connection to my express server, axios throws an error. I have narrowed this down to a CORS issue, but cannot work out why it is blocking a connection through my local IP? I have Access-Control-Allow-Origin: *
set btw. Any ideas? Thanks.
Asked
Active
Viewed 370 times
0

nodeman
- 1
-
If you're running any time of add blockers etc on your phone I'd suggest turning them off. Are you sure the url you're using on your mobile device is formatted correctly? – snazzyy Sep 20 '21 at 02:06
-
Add code snippets, we can't figure out what is wrong without looking at the code – Sachin Ananthakumar Sep 20 '21 at 07:32
-
Nevermind, I still had my API calls set to localhost from a client not running on the same localhost as the API. Changed the API calls to the IPv4 address instead and hey presto. – nodeman Sep 20 '21 at 21:23
-
https://stackoverflow.com/questions/69123274/nextjs-error-in-mobile-devices-while-fetching-data-on-client-side-using-swr/69123877#69123877 – Chemi Adel Sep 20 '21 at 21:31
1 Answers
0
I still had my API calls set to localhost from a client not running on the same localhost as the API. Changed the API calls to the IPv4 address instead and hey presto.

nodeman
- 1