I have this piece of Vue.js:
...
this.$http.post('http://localhost:8000/oauth/token', postData)
.then(response => {
console.log(response)
})
this.$http.get('http://localhost:8000/api/test')
.then(response => {
console.log(response)
})
...
The last get request works fine, but the post doesn't go through due to
XMLHttpRequest cannot load http://localhost:8000/oauth/token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ...
My Cors.php Middleware:
...
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
}
...
Kernel.php:
...
'api' => [
'throttle:60,1',
'bindings',
\App\Http\Middleware\Cors::class,
],
...
I've done php artisan route:list
I noticed that the route ...oauth/token
has the middleware throttle
, it is the only one by default ... I'm following https://laravel.com/docs/5.3/passport#installation
Both (client/server) are running on localhost