[英]HTTP 405 error in angular 5 post data to lumen
在我的角度發布數據中
this.http.post('http://localhost/exampledomain.com/public/postMethod',{title:'sample',method:'POST'},this.headers).subscribe(res => { this.candidateResponse = res.json(); console.log(res.json()); } );
流明
$router->post('postMethod', function (){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Content-Type, Origin');
header('Content-Type: application/x-www-form-urlencoded');
return json_encode(array("name"=>'sample'));
});
錯誤:
405(不允許使用方法)
飛行前的響應具有無效的HTTP狀態代碼405
這是由於跨源問題造成的。1.您可以在Laravel應用中添加一些代碼https://laracasts.com/discuss/channels/laravel/access-control-allow-origin-in-laravel-54/replies/ 392243 2.您也可以使用Angular解決問題。3.您可以添加chrome擴展
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.