laravel / octane

Supercharge your Laravel application's performance.
https://laravel.com/docs/octane
MIT License
3.71k stars 284 forks source link

fix: use capture to populate global request with json array #883

Closed krowinski closed 2 months ago

krowinski commented 2 months ago

To replicate :

Create route with FrankenPHP server.

Route::post('/test', static function (Request $request) {
    return new JsonResponse($request->get('key'));
});

POST json

curl --location 'localhost/test/' \                                                                                                                               
--header 'Content-Type: application/json' \
--data '{"key":"value"}'

Expected "value" Current "{}"

Laravel is using $response = $kernel->handle($request = Request::capture())->send(); in index.php but FrankenPhpClient is just doing Request::createFromGlobals() and its not passing by \Illuminate\Http\Request::createFromBase that populate request using incoming json values using this code fragment.

       if ($newRequest->isJson()) {
            $newRequest->request = $newRequest->json();
        }