// Use compose to create a new laravel project
composer create-project laravel/laravel lara-vue-auth -–prefer-dist
middleware:
Using parameterized middleware in the route defintion
When you're adding middleware to a route definition, you'd normally set it like this:
Route::get('company', ['middleware' => 'auth', function () {
return view('company.admin');
}]);
So, let's add in our parameter to show that the user must have the owner
role:
Route::get('company', ['middleware' => 'auth:owner', function () {
return view('company.admin');
}]);
Note that you can also pass multiple parameters as a comma-separated list:
Route::get('company', ['middleware' => 'auth:owner,view', function () {
return view('company.admin');
}]);
https://mattstauffer.com/blog/passing-parameters-to-middleware-in-laravel-5.1/
JWT type error:
Register middleware && routes:
The simple answer is to set the Access-Control-Allow-Origin
header to localhost
or *
. Here's how I usually do it:
Create a simple middleware called Cors
:
php artisan make:middleware Cors
Add the following code to app/Http/Middleware/Cors.php
:
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
}
// Make middleware global
No comments:
Post a Comment