Friday, 28 September 2018

connecting to local backend from android app

I have my Laravel backend that I am trying to connect to from android app. my hosts file has

   127.0.0.1    my.backend.test

the httpd conf file in my backend is

<VirtualHost *:80>
ServerName      my.backend.test
DocumentRoot    /var/www/mybackend.co.uk/code/public/
DirectoryIndex  index.php
RewriteEngine   On
ErrorLog        /var/www/mybackend.co.uk/code/storage/logs/apache_error.txt

Header set Access-Control-Allow-Origin "http://localhost:4200"

<Directory /var/www/mybackend.co.uk/code/public/>
    AllowOverride All
</Directory>

I can access http://my.backend.test/api/some-route fine from google ARC but not from my phone. I seem to have to use my local ip address but I dont understand how to set that up.

I tried adding

<VirtualHost 192.168.my.ip:8080>
ServerName      my.mobilebackend.test
DocumentRoot    /var/www/mybackend.co.uk/code/public/
DirectoryIndex  index.php
RewriteEngine   On
ErrorLog        
/var/www/mybackend.co.uk/code/storage/logs/apache_error.txt

<Directory /var/www/mybackend.co.uk/code/public/>
     AllowOverride All
</Directory>

to httpd conf and

192.168.my.ip my.mobilebackend.test

to hosts



from connecting to local backend from android app

No comments:

Post a Comment