W
W
Wytpry2018-06-20 00:21:16
React
Wytpry, 2018-06-20 00:21:16

What causes the Error: Network Error?

Good evening! I can't understand why the error is displayed:

Failed to load http://192.168.6786/api/account/signin: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 403.

    Error: Network Error
    at createError (createError.js:15)
    at XMLHttpRequest.handleError (xhr.js:87)

I am attaching the code:
axios.post(apiBaseUrl + "account/signin", payload)
   .then(function (response) {
     console.log(response.data);
     if(response.data.code == 200){
       console.log("Login successfull");
         window.location.href = "https://www.google.ru"; 
       
        
       
     }
     else if(response.data.code == 204){
       console.log("Username password do not match");
       alert(response.data.success);
        
         
     }
     else{
       console.log("Username does not exists");
       alert("Username does not exist");
         
     }
   })
   .catch(function (error) {
     console.log(error);
           
   });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Baev, 2018-06-20
@Wytpry

The error speaks for itself:
Your API is missing the Access-Control-Allow-Origin header , which is required for cross-domain requests (CORS).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question