Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I'm building an application with Vue (VueX, vue-router, ...) and OctoberCMS. I create virtual domain for API and APP in local via MAMP. I had config all CORS via plugin 'rluders-cors' in OctoberCMS.
Route::group(
[
'prefix' => 'api/v1',
'middleware' => ['api','jwt.auth','\Barryvdh\Cors\HandleCors'],
],
function () {
// Routes here
}
);
When I deployed into VPS (Centos 6), I have above response from browser. I had added header in .htaccess file of API. And when I open API dirrectly via browser (turn of jwt.auth middleware), I get all header which set in .htaccess file. But in App, don't work.
I tried to use primary domain for App (abc.example) to call the API from my virtual domain in local (local.local), it still worked. But I tried local App to call the primary API in VPS, it didn't work.
Please help me! Thanks.
In my case, it worked with :