klein / klein.php

A fast & flexible router
MIT License
2.66k stars 290 forks source link

POST route does not run while it will as GET #381

Closed Grimston closed 6 years ago

Grimston commented 6 years ago

Machine 1 OS: Windows 10 Server: nginx PHP: 7.1

Machine 2 OS: CentOS Server: Apache2 PHP: 7.1

$klein->with('/administration/user', function () use ($klein) {
    $klein->respond('/?', function ($request, $response, $service) use ($klein) {
        //Removed but does work.
    });

    //This I want to set to POST only, but for testing...
    $klein->respond('/create', function ($request, $response, $service) use ($klein) {
        die("Works in GET, not in POST");
    });
});

NGINX Config

location / {
        try_files $uri $uri/ /index.php$is_args$args;
}

Apache Config

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]

#RewriteRule ^(.+)$ index.php?uri=$1 [QSA,L]

The code is loaded via it's parent class in a dynamic system allowing the class to just be dropped in and function.

I have similar modules and even others with POST and GET routes, this is the only one that keeps returning a 404 on POST but 200 on GET.

I have tried changing the route even to random numbers and strings to see if it was a reserved word or similar.