{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"CORS Headers","type":"basic","slug":"cors-headers","excerpt":"","body":"[Laravel-cors](https://github.com/barryvdh/laravel-cors) is pre-configured in this repository.\n\nIf you don't need CORS headers, feel free to remove it.\nOr if these headers are failing when your application encounters an error, you can fix it by removing this package and creating the following middleware:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<?php\\n\\nnamespace App\\\\Http\\\\Middleware;\\n\\nuse Closure;\\n\\nclass CorsMiddleware\\n{\\n    /**\\n     * Handle an incoming request.\\n     *\\n     * :::at:::param  \\\\Illuminate\\\\Http\\\\Request  $request\\n     * @param  \\\\Closure  $next\\n     * @return mixed\\n     */\\n    public function handle($request, Closure $next)\\n    {\\n        return $next($request);\\n    }\\n\\n    public function terminate($request, $response)\\n    {\\n        return $response->header('Access-Control-Allow-Origin', '*')\\n        ->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')\\n        ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With');\\n    }\\n\\n\\n}\\n\",\n      \"language\": \"php\",\n      \"name\": \"CorsMiddleware.php\"\n    }\n  ]\n}\n[/block]","updates":[],"order":3,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"57ffd85f755a2e1700c2bb33","__v":0,"createdAt":"2015-12-18T23:29:26.606Z","parentDoc":null,"user":"567082433a32d20d00c45cab","githubsync":"","version":{"version":"3.4","version_clean":"3.4.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["57ffd85f755a2e1700c2bb06","57ffd85f755a2e1700c2bb07","57ffd85f755a2e1700c2bb08","57ffd85f755a2e1700c2bb09","57ffd85f755a2e1700c2bb0a","57ffd85f755a2e1700c2bb0b","57ffd85f755a2e1700c2bb0c","57ffd85f755a2e1700c2bb0d"],"_id":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae","releaseDate":"2016-10-13T18:54:23.018Z","__v":1,"createdAt":"2016-10-13T18:54:23.018Z"},"category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Extras","slug":"extras","order":7,"from_sync":false,"reference":false,"_id":"57ffd85f755a2e1700c2bb0d","createdAt":"2015-12-18T23:14:25.130Z","__v":0,"version":"57ffd85f755a2e1700c2bb05","project":"567083021dabd80d00b122ae"},"project":"567083021dabd80d00b122ae"}
[Laravel-cors](https://github.com/barryvdh/laravel-cors) is pre-configured in this repository. If you don't need CORS headers, feel free to remove it. Or if these headers are failing when your application encounters an error, you can fix it by removing this package and creating the following middleware: [block:code] { "codes": [ { "code": "<?php\n\nnamespace App\\Http\\Middleware;\n\nuse Closure;\n\nclass CorsMiddleware\n{\n /**\n * Handle an incoming request.\n *\n * @param \\Illuminate\\Http\\Request $request\n * @param \\Closure $next\n * @return mixed\n */\n public function handle($request, Closure $next)\n {\n return $next($request);\n }\n\n public function terminate($request, $response)\n {\n return $response->header('Access-Control-Allow-Origin', '*')\n ->header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS, PUT, DELETE')\n ->header('Access-Control-Allow-Headers', 'Content-Type, Accept, Authorization, X-Requested-With');\n }\n\n\n}\n", "language": "php", "name": "CorsMiddleware.php" } ] } [/block]