在应用程序中,laravel我向post返回json对象的地址发送请求。当我在本地服务器上运行应用程序时php artisan serve,post请求http当然是不允许的。为了解决这个问题,我启动ngrok了一个具有安全连接的服务器,但即便如此,
如果您单击地址栏上的键,错误代码仍然是一样的:

请求如下所示:
axios.post("/modal-info", { id: 1 })
.then(async res => {
console.log(await res)
})
.catch(error => {
console.log(error);
})
PSaxios.get("/modal-info").then(...)从地址成功返回对象
PS 我会打开几个小时https://c1597888ac87.ngrok.io

首先,不要忘记在请求标头中发送密钥后
web.php更改Route::get为,如下所示:Route::postcsrf链接到文档中的这一点