'Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs
I have in backend this link backend.com
and for frontend frontend.com
I want to lock my API backend for everyone except my frontend!
my cors.php
<?php
return [
'paths' => ['api/*'],
'allowed_methods' => ['*'],
'allowed_origins' => ['*'],
'allowed_origins_patterns' => [],
'allowed_headers' => ['*'],
'exposed_headers' => [],
'max_age' => 0,
'supports_credentials' => false,
];
Solution 1:[1]
You can add this line in default global config, global main js file or where you use axios call:
axios.defaults.headers.common['Access-Control-Allow-Origin'] = 'frontend.com';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Robert S |