PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 4, 2022

[FIXED] Access-Control-Allow-Origin (Laravel & Vue) CORS CORB error on localhost

 February 04, 2022     api, cors, laravel, vue.js     No comments   

Issue

I use this package and it didn't work (https://github.com/barryvdh/laravel-cors)

enter image description here

addSMS() {
    axios.post('https://smsmisr.com/api/webapi', {
                headers: {
                        'Access-Control-Allow-Origin': '*',
                        'Access-Control-Allow-Methods': 'POST, GET, PUT, OPTIONS, DELETE',
                        'Access-Control-Allow-Headers': 'Access-Control-Allow-Methods, Access-Control-Allow-Origin, Origin, Accept, Content-Type',
                        'Content-Type': 'application/json',
                        'Accept': 'application/json'
                    },
                username: '*****',
                passowrd: '****',
                etc: '',
            })
            .then(function (response) {
                console.log(response);
            })
            .catch(function (error) {
                console.log(error);
            });
        }

please tell me how to fix it it's cors not working for me.


Solution

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 enter image description here



Answered By - Rejoanul Alam
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing