Laravel 5 + AngularJS Cross Domain CORS

后端 未结 7 1524
暖寄归人
暖寄归人 2020-12-31 23:28

I have searched everywhere for an answer but nothing have worked so far. All the listed solutions on stack have not proven to be sufficient.

I get nothing in my lar

相关标签:
7条回答
  • 2021-01-01 00:00

    Add this line before return header("Access-Control-Allow-Origin: *");

    Your code should be

    public function index()
    {
        $posts = Post::with('user', 'tags')->get();
        header("Access-Control-Allow-Origin: *");
        return response()->json($posts);
    }
    
    0 讨论(0)
提交回复
热议问题