HungryBus's avatar

HungryBus wrote a reply+100 XP

3mos ago

There's no redirect there: response()->json([PayerResource::collection($payers)]);.

HungryBus's avatar

HungryBus liked a comment+100 XP

3mos ago

check also what happens at the end of the function, because sometimes the post/patch works fine but its the redirect that fails.

HungryBus's avatar

HungryBus wrote a reply+100 XP

3mos ago

Yeah, might be, however... both PUT & PATCH & DELETE methods not working with The HTTP verb used to access this page is not allowed. 405 HTTP error code.

HungryBus's avatar

HungryBus started a new conversation+100 XP

3mos ago

Hello :)

A very strange bug appears on production. When calling the Laravel 12 API via PUT, the return is 405 Not Allowed, however changing the same method to POST works fine for some reason.

Locally, it works both with PUT/POST.

This is the routes file:

Route::prefix('payers')
            ->name('payers.')
            ->controller(PayerController::class)
            ->group(function () {
                Route::get('/', 'index')
                    ->middleware('abilities:view-payers')
                    ->name('index');

                // This is the problem: changing it to POST works fine
                Route::put('/', 'store')
                    ->middleware('abilities:create-payer')
                    ->name('store');

                Route::patch('{payer}', 'update')
                    ->middleware('abilities:update-payer')
                    ->name('update');

                Route::delete('{payer}', 'destroy')
                    ->middleware('abilities:delete-payer')
                    ->name('destroy');
            });

I have to note, that there is no any conflict between my "caller" app and "callable" app: when I toggle between POST/PUT, I do it in both places.

I also have to note that production "callable" app is being hosted on the Debian server with Plesk installed, served via Nginx. At first, I thought that there might be some directives I should to include to allow additional request verbs, like PUT/PATCH/DELETE, but no - it works fine for other apps on the same server.