Reputation: 411
I have a staging site set up at example.com/staging/public_html. Everything works as per the production site, except for the AJAX GET and POST requests, which all point to:
example.com/myroutehere
rather than
example.com/staging/public_html/myroutehere
here is the start of my AJAX request:
request = $.ajax({
url: "/estimate/{{ $id }}",
My APP_ENV looks like this:
APP_URL=http://example.com/staging/public_html/
(I've tried with and without the trailing slash).
Where is the AJAX request currently getting it's root path from? And how can I force it to use the APP_ENV from the .env file?
Upvotes: 0
Views: 1629
Reputation: 151
You can call from .env Simply like this .
var appUrl ="{{env('APP_URL')}}";
request = $.ajax({
url: appUrl+"/estimate/{{ $id }}",
Upvotes: 1