matt9292
matt9292

Reputation: 411

Laravel ajax calls don't point to env APP_URL

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

Answers (1)

M.Islam
M.Islam

Reputation: 151

You can call from .env Simply like this .

var appUrl ="{{env('APP_URL')}}";
request = $.ajax({
    url: appUrl+"/estimate/{{ $id }}",

Upvotes: 1

Related Questions