I'm trying to get the API working for Spark and have encountered a problem.
Using the home vue.js component that get's shipped with Spark I can make, and receive a response, to the api routes. However, when I try to create a new component, it returns a 401 Unauthorized and logs me out.
If I try to replicate it by using Postman and send a Post request to the same route (/api/test) it works as long as I provide the api_token querystring value with a valid API token.
I found that adding the 'web' middleware to the api.php file works if I use the vue.js component, but then it breaks if I try to use Postman.
This is the component that I'm having the problem with.
Vue.component('domains', {
props: [],
ready() {
this.$http.get('/api/test').then(response => {
console.log(response.data)
})
}
});
This is my api.php file:
Route::group([
'prefix' => 'api',
'middleware' => ['auth:api']
], function () {
Route::get('test', function(){
return "test";
});
});
I'm using the latest version of Spark (1.0.3) and Laravel (5.2.30).