localhost附加到RequestURL,而$ http.post使用angularjs

时间:2015-06-28 09:17:58

标签: angularjs

我使用json-server(https://github.com/typicode/json-server)作为模拟服务器。我的json服务器运行@ 127.0.0.1:3001。当我试图使用$ http.post()从我的应用程序发送数据到该json服务器时,该应用程序运行在localhost:3000。其帖子如http://localhost:3000/127.0.0.1:3001/tasks/ ....

当我查看其他帖子时,他们建议在服务器端启用CORS。但我不知道如何启用CORS到json服务器。任何人都可以帮我解决这个问题。

代码:

 return $http.post(config.baseURL+"/tasks"+app,{headers: {'Content-Type': 'application/json'} })
            .then(success)
            .catch(fail);

请帮助。 config.baseURL有127.0.0.1:3001。 PFA屏幕截图enter image description here 期待技术人员的帮助......

0 个答案:

没有答案