same-origin policy and CORS – what’s the point?

The important thing to note here is that if the user is signed in to a site and the request deletes a post by the user, then the following code will delete the user’s post: <script src=”″ /> This is called a CSRF/XSRF attack (cross-site request forgery). This is why most server-side web … Read more

Adding Access-Control-Allow-Origin header response in Laravel 5.3 Passport

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’); } You can replace … Read more