When running app on mobile doesn't make get and post data, but in the web version it works

hi dears, so when i run my app with ionic serve and I have already a build backend with laravel , I run it with xampp and the data requests work correctly in the web version , otherwise when I run it on the mobile device using ionic cap run android -l --external with same wifi as phone as PC … the data requests doesn’t work


Most likely you need to open up the port in your PC’s Firewall to allow Android to access it.

API service is using, that’s localhost.

But the API is not running on your mobile, is it?

Good point. So, @ayoub1920, you need to use the IP address of your PC for API service base URL and you need to open up port 8000 on your PC in the firewall.

yess , it is , the chrome inspect return error 404 , erroe in fetcheing with get and post

please if you can to clear more what did you mean with open up port 8000!!!

is it?
you say you are running your API server in your mobile device where you are testing?

Your API server is running in your computer, not in your mobile phone. If you use or localhost, it will try to connect with the own mobile device and the server is running in the computer and that’s why you get a 404.

Also if using https there are a lot of chances that the certificates are not valid for mobile testing as mobile devices don’t usually like self signed certificates.

So try using the computer IP and http (the IP usually looks like 192.168.1.x)

By default, computers block incoming traffic via a Firewall.

If on Windows, here are directions - How to open ports in Windows Firewall | Windows Central.

If Linux, most likely you would use ufw - Gufw - Community Help Wiki

You need to open the incoming port 8000.