We are using the vue-bulma-admin
scaffold on a project, which already uses webpack, and we can't seem to perform any POST/PUT requests to our API (which already sets access-cross-allow-origin headers to *), only GET requests works. From different front-ends that consumes our API, we don't have this problem, only with this specific front-end, which gives as this common error:
"No 'Access-Control-Allow-Origin' header is present on the requested resource."
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested
resource.
We already tried to set custom headers on axios/vue-resource
, but with no success. As I said, using the same routes through Postman / different front-ends or with the CORS chrome extension, everything works fine.
Any ideas to work around this?
My Middleware Cors in Laravel API.
<?php
namespace App\Http\Middleware;
use Closure;
class Cors
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
return $next($request)
->header('Access-Control-Allow-Origin', '*')
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
}
}