I use this package and it didn\'t work (https://github.com/barryvdh/laravel-cors)
addSMS() {
axios.post(\'https://smsmisr.com/api/webapi\', {
As you have no access in API's source code so there is nothing to do with .htaccess
or adding 'Access-Control-Allow-Origin': '*',
in script. But still you can eradicate this error by opening chrome browser with disabled security mode
In windows run CMD (press together windows button and R
key from keyboard. Then type cmd
in box and enter).
Secondly go to C
drive (in CLI) or where your chrome installed (using cd
command) then run following command
“Program Files (x86)\Google\Chrome\Application\chrome.exe” –-allow-file-access-from-files --disable-web-security --user-data-dir --disable-features=CrossSiteDocumentBlockingIfIsolating
It will open your browser in disabled web security mode. Once you done it you can test now with this kind of CORS
or CORB
error.
note: before running this command make sure there are no chrome are opened already.
Program Files (x86)\Google\Chrome\Application\chrome.exe
this should be your chrome installed path
However after opening browser it will show as below, dont panic & dont close this message. if you close this message it will again through this CORS
or CORB
error
Update config/cors.php
'supportsCredentials' => false,
'allowedOrigins' => ['*'],
'allowedHeaders' => ['*'],
'allowedMethods' => ['*'], // ex: ['GET', 'POST', 'PUT', 'DELETE']
'exposedHeaders' => ['*'],
'maxAge' => 0,
then run
php artisan config:cache
command i think it will help you