AngularJS + ServiceStack + Node.js作为代理?

我已经在angularjs中创build了一个应用程序。 服务器端由服务栈覆盖,我想处理由服务栈应用程序提供的json文件。 要做到这一点,我使用angularjs中的以下代码:

taskListApp.factory('Fact', function ($resource) { return $resource("http://localhost:55267/hello?format=json", {}, { query: {method: 'GET', url: "http://localhost:55267/hello?format=json"}, }); }); 

然而,我得到的错误在控制台中的相同的原点策略,缺lessCORS头。

我试图使用默认的node.js模板来创build一个proxxy服务器,但是我对我应该使用哪个端口毫无头绪。 任何标题?

编辑:这是我的node.js代码,它返回未处理的“错误”错误

 httpProxy.createServer({ target:'http://localhost:55267' }).listen(8003); http.createServer(function (req, res) { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(55267); 

不知道这是否能解决节点的问题,但是如果你想添加CORS Response Headers到ServiceStack响应,你需要在你的AppHost的Configure()注册CORS插件:

 Plugins.Add(new CorsFeature()); 

如果您想将CORS响应头添加到ServiceStack响应中。 请添加下面的行:

 res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");