I'm trying to work out if it's possible to use the regular Laravel Authentication routes with blade/views for basic Auth then load the SPA (Vue.js with it's own router) and make calls to the API via Dingo?
At the moment I have this at this top of my routes.php
, which works:
// All routes through web middleware
Route::group(['middleware' => 'web'], function () {
// Authentication
Route::auth();
// Authenticated routes
Route::group(['middleware' => 'auth'], function () {
// Load main SPA
Route::get('/', 'AppController@spa');
});
});
app.domian.com/
is protected with Auth and thats the route which the SPA uses. I use the standard, built in, Laravel Auth pages (non SPA) so when the user is logged in or registered it allows access to the home route and loads the SPA.
What I would like to do is use Dingo from this point onwards. So calls to app.domian.com/api/*
are all handled by Dingo.
I've added this to the same routes file:
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function($api) {
$api->group(['middleware' => 'auth'], function ($api) {
// API prefix: api
$api->get('user', function($api) {
return Auth::user();
});
});
});
This doesn't seem to work.
It is even possible to use Dingo in this way or do I have to forfeit the built in Auth for something like JWT. I'm hoping to do that in the future, but for now I just need to get this working.