0
votes

So, this is my first post on stack overflow, if I missed something please let me know.

So I have some sort of a weird problem that I can't figure out. I have a laravel 8 application, worked on it on my machine and things seemed ok, after uploading it on a cpanel I got stuck with this weird problem.

I have a form:

<form action="{{ route('articles.store') }}" method="POST" class="form-horizontal" role="form" enctype="multipart/form-data">
    @csrf
    ...
    <input type="submit" value="Post" class="btn btn-primary">
</form>

The form has some inputs, a textarea and a file input. Those are my routes:

Route::prefix('articles')->middleware(['auth:sanctum', 'verified'])->group(function(){
    Route::get('/create', [\App\Http\Controllers\ArticleController::class, 'create'])->name('articles.create');
    Route::post('/store', [\App\Http\Controllers\ArticleController::class, 'store'])->name('articles.store');
});

When I submit the form I get the The GET method is not supported for this route. Supported methods: POST. error.

I opened the Network console in chrome, checked the preserve logs checkbox and did the request again and in the list it looks like this did the POST request, but received a 405

A picture of the call in the network tab of chrome inspector

I checked in my cpanel Select PHP Version page the post_max_size and upload_max_size options and they are at 1G.

Also, tried to change the route to PUT and use @method('PUT') but I got the same result.

Also, a weird part is that if I submit the form with no content it works, I get the validations back as intended, but as soon as I fill even one of the fields I get the method not allowed error.

Maybe you guys have any idea what is happening here and point me in the right direction.

Thanks!

1
Can you test it again, just remove the middlewares ? - Svetoslav
@justMike do you have any hidden field in the form? Could you post the all fields that are within the form? Also try to run command php artisan route:list and see if you are seeing the correct route for articles.store - tanay jha
I have no hidden fields in my form, only the csrf from the @csrf. Runned the route:list, this is it: | | POST | articles/store | articles.store | App\Http\Controllers\ArticleController@store | App\Http\Middleware\EncryptCookies | - justMike
It looks like I can't post the form, becaus the content it is too large. - justMike
405 methodNotAllowed exception indicates that a route doesn't exist for the HTTP method you are requesting. @justMike are you uning http or https? - sta

1 Answers

0
votes

Can you clear the route cache with the following command on the server and try again?

php artisan route:cache