Ad

Nginx Laravel GET Request Doesn't Send Array

- 1 answer

I'm using Laravel with NGINX and I can't recieve GET requests for some reason. They work perfectly with Apache (XAMPP).

This is my URL with parameters that I want to pass:

/table-search-client?model=Client&column=name&search=UAB

In my controller for this example I used dd() to just display the passed in array. This is what I get with Apache (correct):

array:3 [
  "model" => "Client"
  "column" => "name"
  "search" => "UAB"
]

This is what I get with Nginx (incorrect):

array:1 [
  "query_string" => null
]

Post method works perfectly, but I want to use Laravel's pagination and, with my understanding, that requires GET method.

I assume this is some sort of configuration problem, but I don't know what and where to edit in the Nginx config files.

Any suggestions?

Ad

Answer

So I managed to find the problem in the NGINX config file which is located in etc/nginx/sites-available/default.

My previous configuration was like this:

location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?query_string;
    }

So fore some reason while installing Nginx the $ sign was missed. So I only had to add it before query_string, restart Nginx and everything started working. So the final config looked like so:

location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }
Ad
source: stackoverflow.com
Ad