ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

Frappe. Cross-Origin Request Blocked on localhost


#1

Hi! I am trying to do some integration with frappe server that is running on localhost (port 8000). My goal is to send login request from React app, that app also runs on localhost (port 3000). I am sending request using axios:

  const loginUrl = 'http://127.0.0.1:8000/api/method/login/';  
  const options = {
       usr: 'someuser@gmail.com',
       pwd: 'some_password'
    };
    const config = {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
       }
    }
    axios.post(loginUrl, options, config)
    .then((response) => {
      console.log(response);
    })
    .catch((error) => {
      console.log(error);
    });

Traceback of werkzeug is:

INFO:werkzeug:127.0.0.1 - - [10/Jan/2019 09:53:28] "POST /api/method/login/ HTTP/1.1" 200

So, as I can understand, server is getting my request and resposing with success code?
But in browser console:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:8000/api/method/login/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

And result of console.log(error) is

Error: "Network Error"

Is it problem with my frappe server? Thanks in advance