Route::patch('/todo/{id}/completed',function($id){//Request $request
$article=App\Article::find($id);
$article->completed=!$article->completed;
$article->save();
return $article;
})->middleware('cors:api');
this.axios.patch('http://127.0.0.1/laravel/public/api/todo/'+ todo.id +'/completed').then(response=>{
console.info(response.data)
todo.completed=!todo.completed
})
这段没法互通
XMLHttpRequest cannot load http://127.0.0.1/laravel/public/api/todo/10/completed. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 403.