Hello,
I'm using Backpack/Base ans Backpack/Crud. It's working well on my localhost but as soon as I push it on the production environment, all the filters aren't working anymore.
When I check the request in my Network (search?myVar=xxx), I have a 200 with results but results that aren't filtered. So I have all my table back.
It's problaby an environment issue. But I don't see where i'm wrong.
Here is my localhost configuration :
My production environment :
On both of them, datas are generated by seeders, so datas are the same.
Is there anyone who had the same issue ?
Thanks.
@Sidjoo Perhaps show us some of your code so we can test it?
I do have the exact same problem - works local but not on production server.
Here is the Network Call of one of my filters:
https://www.xxxxx.xx/admin/mytest/search?campaign_id=test&campaign_id_text=test
Result:
{"draw":8,"recordsTotal":26464,"recordsFiltered":26464,"data":[["<td>79J43O<\/td>",....
This will always return the not filtered list and not the filtered list on production but does filter the list on my local host.
Using the Filter Input Box works but the input is transferred as POST Request to the server
I was able to find the problem - it is related to this code part in
laravel/vendor/backpack/crud/src/PanelTraits/Filters.php
/**
* Determine if the current CRUD action is a list operation (using standard or ajax DataTables).
* @return bool
*/
public function doingListOperation()
{
$route = $this->route;
switch ($this->request->url()) {
case url($this->route):
if ($this->request->getMethod() == 'POST' ||
$this->request->getMethod() == 'PATCH') {
return false;
}
return true;
break;
case url($this->route.'/search'):
return true;
break;
default:
return false;
break;
}
}
}
The problem is caused by my hosting setup. The larvel instance is behind a reverse proxy which is handling the ssl connection. the request recieved by the site are all http but all urls generated by the site are with https. As this code is comparing the urls including hostname and protocol the compare fails:
$this->request->url(): http://www.xxxxx.xx/blog/lv/admin/mytest/search
$this->route: https://www.xxxxx.xx/blog/lv/admin/voucher
$this->route.'/search': https://www.xxxxx.xx/blog/lv/admin/mytest/search
The solution was to use app('request')->setTrustedProxies( array( 'XXX.XXX.XXX.XXX',)); in file laravel/app/Providers/AppServiceProvider.php in public function boot() to get the app into a mode where it will create the request url similar to the route url.
'XXX.XXX.XXX.XXX' is the ip(s) of the reverse proxies which are provides by the HTTP Header.
In my case I also had to wrap the base Symphonie request laravel/public/inde.php into a custom request which added missing headers from the proxy to switch protocol from http to https:
$response = $kernel->handle(
//$request = Illuminate\Http\Request::capture()
$request = App\Http\CustomRequest::capture()
);
for simpler environments I suggest to use fideloper/proxy
@aheissenberger where do you use app('request')->setTrustedProxies ?
I have the same problem. I don't understand everything what you explain :D but I would like to test your solution.
Ok got it the solution thanks to heroku documentation.
https://devcenter.heroku.com/articles/getting-started-with-laravel#trusting-the-load-balancer
thanks @aheissenberger
I had the same problem. I'm running laravel Backpack in ELB and it wasn't enough with the fideloper/proxy package. I used this article to fix the problem: Laravel 5 : SSL routes behind a load balancer
Most helpful comment
Ok got it the solution thanks to heroku documentation.
https://devcenter.heroku.com/articles/getting-started-with-laravel#trusting-the-load-balancer
thanks @aheissenberger