App Ionic+Laravel on my smartphone, Can i run it locally? - laravel

I created an application using ionic for the front-end and laravel for the back-end, I wanted to test the app on my smartphone without buying hosts, etc ...
I created the apk (using ionic cap build android), I installed it on the device and obviously the calls to the database do not work ...
searching on the internet I tried to replace localhost:8000 with my-ip-address:8000 but:
nothing, although if I search from the browser of my smartphone I enter the default view of the laravel project.
now if I try to start the livereload (ionic serve) on my pc, it gives me error: Failed to load resource: net :: ERR_NAME_NOT_RESOLVED.
Is it possible to test my application on my smartphone by running Laravel locally?

You can give your API an external URL using a tool like NGROK or Local tunnel which will give you a public URL for your local API.
https://ngrok.com/
https://github.com/localtunnel/localtunnel

Related

how to build a mobile application created with ionic and laravel?

I have developed an application using ionic for the frontend and laravel for the backend ... now I wish I could see it running on my phone, but I don't know what I need to buy as hosting and database, which files should I upload etc ... any help?
php version: 7.4.1
laravel framework: 8.78.1
phpmyadmin: 5.0.1
mariaDB: 10.4.11
mysql: 7.4.1
I see two questions:
How to try the app on your phone:
When you build an App, you can read here about how to deploy it to your phone by e.g. transferring an APK to your Android phone. To install the APK, you have to enable the developer-features in your phone's settings.
How to host the Laravel backend (to try it with your app):
You could use your local development environment. E.g. when your laptop with your laravel backend running and your phone are in the same Wifi-Network, you just need to expose the project to the network so that the app on you phone can reach it.
Hosting it on a public server would require you to have a domain. The server has to meet the needs of your project. You have to look for the correct php-version, php extensions, etc (Laravel Docs on Server requirements). For a small project, most shared-hosting servers with ssh-access and MySql database would fit. You could put some more effort by choosing a server from digital ocean, where a droplet is just a few bucks but you have to do all the configuration by yourself.
Hope that helps!
For running it on mobile you could use capacitor with ionic Capacitor

Could the server and app run in the same domain?

The situation I met is that.
I design a frontend app by React, but I want to connect to MongoDB.
From what I knew so far, I could only connect to MongoDB in the backend. So, I use the express to set up a server but when I try to connect the frontend to the backend, the answer I found seems to tell me that I should run the server and the app on different domains, so I should run the server and app on different Heroku apps.
Could I put the server and app in just one Heroku app and connect between them?

React native project created by expo how to enable http requests to a server on the localhost

as the title suggests I've used the react native expo quick start guide and managed to setup a basic project. Everything worked just fine until it came to making fetch requests to my local server by laravel 8. It seems both android and ios don't allow making http calls unless you change some config in your android folder which I don't have for using expo. Tried googling for my answer but I keep running into dead ends. Is there any way to enable this or should I try migrating my back-end temporarily to heroku or something similar? Thank you for reading.
Edit: Forgot to mention each time i make a call to the wrong route I immediately get Network error while hitting the right routes throws an unresolved promise

AWS cannot access Laravel API from mobile browser on 4G/LTE network

I have deployed my first Laravel project on AWS and i am trying to communicate to my REACT NATIVE mobile app through the Laravel API.
The problem is that on WIFI network everything works perfectly but in 4G/LTE network i keep getting response error 500. I have tried changing the permissions on AWS but nothing is working
Error 500 means its a server error not react native.

Laravel won't route on production server

Just getting started with laravel and have run into some trouble.
Before committing to using laravel I wanted to build a very basic web app to test the waters via homestead and then move that web app to a remote server in order to see how easy the process was.
So I've got homestead up and running and have built a very basic web app and it works perfectly locally.
However when I moved the laravel project onto the remote server the routing stopped working.
For example locally testProject.dev/contact takes me through to a mock 'contact us' view. However when I try that on productionServer.com/contact I'm greeted by a 403 'you do not have permission to access contact on this server'.
Am I missing something in laravel here or is this an issue with the sever setup?
Any help would be greatly appreciated. Thanks
Update -> This turned out to be an issue with another piece of software running on the server. Thanks for all the help.

Resources