I'm having this error trying to log in with an existing user using Laravel Passport and vue.js. But when I log in it gives a 404 Uncaught (in promise) error. When I look at network it says "Cannot POST /oauth/token"
This is my login.vue script
import {localhost} from '../../config'
export default {
name: 'logIn',
data () {
return {
email: 'elector_user@arteveldehs.be',
password: 'elector_password'
}
},
methods: {
handleLoginFormSubmit () {
const data = {
client_id: 2,
client_secret: 'PAzgzdNUY65z0xWRXobb0TnA7DHYHNtNwIgVykpl',
grant_type: 'password',
username: this.email,
password: this.password
}
this.$http.post(localhost + '/oauth/token', data)
.then(response => {
console.log(response)
})
}
}
}
This is my Kernel.php
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
\Illuminate\Session\Middleware\StartSession::class,
\Barryvdh\Cors\HandleCors::class
];
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
//\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
\Laravel\Passport\Http\Middleware\CreateFreshApiToken::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
This is my RouteServiceProvidor.php
public function map(Router $router)
{
Passport::routes();
$this->mapWebRoutes($router);
$this->mapApiRoutes($router);
}
protected function mapApiRoutes(Router $router)
{
$router->group([
'middleware' => ['api'],
'namespace' => $this->namespace,
], function ($router){
require app_path('Http/routes.php');
});
}
this is my app.php
Laravel\Passport\PassportServiceProvider::class,
Laravel\Tinker\TinkerServiceProvider::class,
via hxwtch