skip to Main Content

I am building a web application using Laravel for APIs and React for the frontend . I want to test the app on a mobile phone. I usually test React alone, and it works, but the information from the backend is not working (authentication, CRUD, etc.). Can I access it? I run React using npm run dev — –host and Laravel using php artisan serve –host=0.0.0.0 –port=8000, but nothing is displaying except the static data.

2

Answers


  1. You can try this. Find the local IP of your PC running the localhost, then append the port to that IP when on your phone i.e. 192.168.1.5:3000.

    Another solution is to use ngrok which is super easy to get running.

    Login or Signup to reply.
  2. Try this:

    1. Run ipconfig
    2. Grab your IPv4
    3. Run php artisan serve --host=<yourIPv4>
    4. In your React code change the API request URL to your server’s address, probably http://<yourIPv4>:8000

    Note: of course your phone and your serve must be connected to the same network

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search