简体   繁体   English

为什么发布请求不起作用并被重定向?

[英]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我是 laravel 和 vue 的初学者,当我向服务器发出 post 请求时遇到路由问题,它告诉我请求被重定向,我不知道问题出在哪里,因为 get 请求正常工作,请帮我

vue code代码

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

my route in laravel我在 laravel 的路线

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

You should remove the trailing / in your URI.您应该删除 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.许多服务器出于不同的原因将带有斜杠的任何 url 重定向到没有斜杠的版本,其中之一是 SEO。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM