question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cross domain browser version

See original GitHub issue

Nodejs:

var  axios  =  require("axios");  

axios.get("https://www.google.com.vn")  
    .then(function (response)  {  
      console.log(response);  
       })  
    .catch(function (error)  {  
         console.log(error);  
     });

It work perfect ! But when i run it in browser version:

<script src="https://npmcdn.com/axios/dist/axios.min.js"></script> 
<script>
axios.get("https://www.google.com.vn")  
    .then(function (response)  {  
      console.log(response);  
       })  
    .catch(function (error)  {  
         console.log(error);  
     });
</script>

Error:

XMLHttpRequest cannot load https://www.google.com.vn/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
localhost/:9 Error: Network Error(…)

What i missing ? Sorry i new to axios

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ngtranthanhtoancommented, Sep 26, 2017

I’m using jquery and it’s working just fine. But it’s still got error with axios

0reactions
Uniphixcommented, Nov 12, 2016

Yeah I am getting this issue to and it’s driving me nuts, only happening on firefox

Read more comments on GitHub >

github_iconTop Results From Across the Web

Same-origin policy - Web security | MDN
Browsers block stylesheet loads if it is a cross-origin load where the MIME type is incorrect and the resource does not start with...
Read more >
Cross-Origin Resource Sharing | Can I use... Support tables ...
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
Cross-origin resource sharing - Wikipedia
Cross -origin resource sharing (CORS) is a mechanism that allows restricted resources on a web page to be requested from another domain outside...
Read more >
Cross-Origin Requests (CORS) in Internet Explorer, Firefox ...
Below we describe how to enable cross-origin requests in each of 4 major browsers. In FireFox, Safari, Chrome, Edge and IE 10+. To...
Read more >
Cross Domain - CORS
List of feature: - Allow cross domain - Customize Url pattern base on Javascript Regex - Allow enable, disable - Very friendly interface ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found