Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nicktr's avatar

MethodNotAllowedHttpException - only on production website

I'm building an e-commerce site, and everything works fine on my local host and on my staging server (exactly the same environment as my prod server), however, when I deploy the same code to my production server, I get a

MethodNotAllowedHttpException in RouteCollection.php line 218:

error when I try to make a purchase. Here's the full output.

1. in RouteCollection.php line 218
2. at RouteCollection->methodNotAllowed(array('POST')) in RouteCollection.php line 205
3. at RouteCollection->getRouteForMethods(object(Request), array('POST')) in RouteCollection.php line 158
4. at RouteCollection->match(object(Request)) in Router.php line 766
5. at Router->findRoute(object(Request)) in Router.php line 621
6. at Router->dispatchToRoute(object(Request)) in Router.php line 607
7. at Router->dispatch(object(Request)) in Kernel.php line 268
8. at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
9. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
10. at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
11. at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
12. at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
13. at Pipeline->then(object(Closure)) in Kernel.php line 150
14. at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 117
15. at Kernel->handle(object(Request)) in index.php line 53

Here is my route

Route::post('/charge/{antique}/auth', 'OrderController@authoriseCharge');

It's complaining about the Post method when clearly my route uses post.

The only difference between my staging and production server is the production is using live Stripe Keys to make the purchase etc, but it doesn't even get that as far as the controller function, so i'm baffled as to what the issue could be, and not sure how I debug it any further.

Any ideas what could be causing this?

Thanks

0 likes
4 replies
nicktr's avatar

It's a form submission:

<form data-persist="garlic" action="/charge/{{ $antique->slug }}/auth" method="post" id="payment-form">
Snapey's avatar

check in your browser inspector, network tab, is the $antique->slug being inserted correctly?

Is production also running in the root folder?

nicktr's avatar

Whoops, my bad..... I was using my test stripe public api key, not my live one. I had made an error in the way I was choosing the right one based on my environment.

Facepalm.

Thanks for helping out anyway!

Please or to participate in this conversation.