Search code examples
phplaravelvue.jsplesk

Why are post requests not working and getting redirected?


I am a beginner with laravel and vue and I have a problem with routes when I make post requests to the server it tells me that the request was redirected, and I don't know where the problem is since the get requests work normally, please help me

vue code

 await this.form.post('/api/add_tramite/').then(response=>{
                console.log(response.data);
                this.fecthtramitesper();
                this.close();
          })

my route in laravel

Route::post('add_tramite',[tramiteController::class,'agregar_tramite']);

Solution

  • You should remove the trailing / in your URI.

    await this.form.post('/api/add_tramite').then(response=>{
    

    many servers redirect any url with trailing slash to the version without the slash for different reasons, one of them being SEO.