发布到Laravel API的正确技术

时间:2016-10-05 11:00:15

标签: php laravel ember.js

我在使用Ember发布我的Laravel API时出现问题。我不断收到COR的错误,当我尝试将正确的标题添加到我的商店方法时,错误仍然存​​在。我已经研究了一个小时,没有结果。任何帮助将不胜感激。这是我的store()方法的代码......

$statusCode = 200;
$libraries = $request->all();
$library = Library::create($libraries);
$criteria = $library->toArray();
 return Response::json([
     'library' => $criteria],
      $statusCode);

1 个答案:

答案 0 :(得分:0)

尝试这样做

HTTP /中间件/ VerifyCsrfToken.php

使用api启动路由

例如myapp.com/api/login

public function handle($request, Closure $next)
{
  if (!$request->is('api/*'))
  {
    return parent::handle($request, $next);
  }

  return $next($request);
}