I have a laravel
project contains an RestFull API. I want to access to this API from android studio. I use retrofit
library.When I run server through artisan
, can’t access localhost
laravel
app routes to android studio.According to this question accessing-localhost-laravel-app-routes-to-android-studio-failed, I change base url to http://192.168.1.103:8000/halamooz/public/api/
and run the laravel app with apache
server.For this work, I follow this guideline Laravel practical guide for using XAMPP.Of course I don’t use XAMPP
and install apache server individually. I access web route from browser but when I try to access API route from postman
or android studio I receive 404 page not founded
error.What is my mistake?
I put this lines in httpd-vhosts
file:
<VirtualHost *:80>
DocumentRoot "C:/apache/htdocs/halamooz/public"
ServerName exampledomain.com
ServerAlias exampledomain.com
<Directory "C:/apache/htdocs/halamooz/public">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
2
Answers
I finally did these steps and My problem solved.
laravel
project intoC:apachehtdocs
.notepad
app and openhosts
file fromC:WindowsSystem32driversetc
path and add this line to end of file.Step 3: Open
httpd-vhosts
file fromC:apacheconfextra
path and add these lines to end of file:Step 4:Uncomment this line from
C:apacheconfhttpd.conf
file.postman
or android studio project.In httpd.conf file find
and below that write
Then goto httpd-vhosts.conf
Replace DocumentRoot with your path of project. Hope this help you