{"action":"created","issue":{"url":"https://api.github.com/repos/dingo/api/issues/576","labels_url":"https://api.github.com/repos/dingo/api/issues/576/labels{/name}","comments_url":"https://api.github.com/repos/dingo/api/issues/576/comments","events_url":"https://api.github.com/repos/dingo/api/issues/576/events","html_url":"https://github.com/dingo/api/issues/576","id":100604039,"number":576,"title":"Conflict with barryvdh/laravel-cors","user":{"login":"jloosli","id":617816,"avatar_url":"https://avatars.githubusercontent.com/u/617816?v=3","gravatar_id":"","url":"https://api.github.com/users/jloosli","html_url":"https://github.com/jloosli","followers_url":"https://api.github.com/users/jloosli/followers","following_url":"https://api.github.com/users/jloosli/following{/other_user}","gists_url":"https://api.github.com/users/jloosli/gists{/gist_id}","starred_url":"https://api.github.com/users/jloosli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jloosli/subscriptions","organizations_url":"https://api.github.com/users/jloosli/orgs","repos_url":"https://api.github.com/users/jloosli/repos","events_url":"https://api.github.com/users/jloosli/events{/privacy}","received_events_url":"https://api.github.com/users/jloosli/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-12T18:21:29Z","updated_at":"2016-01-26T17:53:55Z","closed_at":"2015-09-23T19:27:25Z","body":"I don't know if this is a bug on dingo/api or barryvdh/laravel-cors side, or if it's just that I messed up with the implementation, but I built up an api using this package and wanted to use https://github.com/barryvdh/laravel-cors handle the CORS side of things. For some reason, couldn't ever get the OPTIONS requests to return the correct information when going through the dingo/api. For example, my routes file looked somewhat like the following:\r\n\r\n```\r\n$api = app( 'Dingo\\Api\\Routing\\Router' );\r\n$api->version( 'v1',['middleware'=>'cors', function ( $api ) {\r\n    $pong = function () {\r\n        return \"pong\";\r\n    };\r\n    $api->get( '/ping', $pong );\r\n    $api->put( '/ping', $pong );\r\n    $api->post( '/ping', $pong );\r\n    $api->delete( '/ping', $pong );\r\n}\r\nRoute::match(['get','put','update','delete','post'], '/test', ['middleware'=>'cors', 'uses' => function () {\r\n    return \"Test\";\r\n}] );\r\n```\r\n\r\nWhen running cors requests through the standard laravel route, I didn't have any problems. However, when running through the dingo api router (/ping), the OPTIONS preflight wouldn't return the correct information. I then tried adding `\\Barryvdh\\Cors\\HandleCors::class` to the `$middleware` array in the kernel, and still no luck. I finally got it working by adding both HandleCors and `\\Barryvdh\\Cors\\HandlePreflight::class` to the `$middleware` array, even though it looks like the boot process should be dynamically adding that anyway. Is there something that I should be doing to ensure that the routeMiddleware is functioning properly?\r\n\r\nSo, to sum things up, the fix for me is to forget using the routeMiddleware and make the middleware look like the following:\r\n\r\n```\r\n    protected $middleware = [\r\n        \\\\ ... All the normal middleware stuff ... \\\\\r\n        \\Barryvdh\\Cors\\HandleCors::class,\r\n        \\Barryvdh\\Cors\\HandlePreflight::class\r\n    ];\r\n```\r\n\r\nAlso, the required composer items are as follows:\r\n\r\n```\r\n    \"require\": {\r\n        \"php\": \">=5.5.9\",\r\n        \"laravel/framework\": \"5.1.*\",\r\n        \"dingo/api\": \"~0.10\",\r\n        \"tymon/jwt-auth\": \"~0.5\",\r\n        \"doctrine/dbal\": \"~2.3\",\r\n        \"watson/validating\": \"~1.0\",\r\n        \"guzzlehttp/guzzle\": \"~5.0\",\r\n        \"guzzlehttp/oauth-subscriber\": \"0.2.*\",\r\n        \"barryvdh/laravel-cors\": \"0.7.x\"\r\n    },\r\n    \"require-dev\": {\r\n        \"fzaninotto/faker\": \"~1.4\",\r\n        \"mockery/mockery\": \"0.9.*\",\r\n        \"phpunit/phpunit\": \"~4.0\",\r\n        \"phpspec/phpspec\": \"~2.1\",\r\n        \"barryvdh/laravel-ide-helper\": \"^2.0\"\r\n    },\r\n```"},"comment":{"url":"https://api.github.com/repos/dingo/api/issues/comments/175141441","html_url":"https://github.com/dingo/api/issues/576#issuecomment-175141441","issue_url":"https://api.github.com/repos/dingo/api/issues/576","id":175141441,"user":{"login":"odranoelBR","id":7774534,"avatar_url":"https://avatars.githubusercontent.com/u/7774534?v=3","gravatar_id":"","url":"https://api.github.com/users/odranoelBR","html_url":"https://github.com/odranoelBR","followers_url":"https://api.github.com/users/odranoelBR/followers","following_url":"https://api.github.com/users/odranoelBR/following{/other_user}","gists_url":"https://api.github.com/users/odranoelBR/gists{/gist_id}","starred_url":"https://api.github.com/users/odranoelBR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odranoelBR/subscriptions","organizations_url":"https://api.github.com/users/odranoelBR/orgs","repos_url":"https://api.github.com/users/odranoelBR/repos","events_url":"https://api.github.com/users/odranoelBR/events{/privacy}","received_events_url":"https://api.github.com/users/odranoelBR/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T17:53:55Z","updated_at":"2016-01-26T17:53:55Z","body":"LeBlaaanc Solution works \\o/ Tks"}}