node.js - PhoneJS w Ripple模拟器无法连接到本地 Node 服务器

标签 node.js mongodb ripple phonejs

我想用数据绑定(bind)到本地 node.js 数据服务器(运行在 localhost:3000,数据库 MongoDB)来测试 PhoneJS 应用程序 它在我的浏览器 ( Chrome ) 中运行良好:

$.get('http://127.0.0.1:3000/Categories') get correctly the data... 

现在尝试模拟移动设备,我通过 Ripple 模拟器运行它。该应用程序在模拟器中显示正确,但在尝试从 Node 服务器获取数据时失败....

 Failed to load resource: the server responded with a status of 500 (Internal Server Error) https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//127.0.0.1%3A3000/Categories

回归

   {
  "code": "ECONNREFUSED",
  "errno": "ECONNREFUSED",
  "syscall": "connect"
   }

我是否遗漏了一些重要参数?

这是我的 server.js :

var express = require('express'),
categories = require('./routes/category'),
products = require('./routes/product');

var app = express();

cors = require('./cors');
app.use(cors);

// categories
app.get('/categories/:id', categories.findById);
app.get('/categories', categories.findAll);

// products
app.get('/categories/:id/products', products.findByCategory);
app.get('/products/:id', products.findById);
app.get('/products', products.findAll);

app.listen(3000);
console.log('Listening on port 3000...');

最佳答案

Ripple 模拟器默认启用“远程跨域代理”。对于本地主机连接,在“设置”可折叠组中禁用它(或设置为本地,如果您的服务不兼容 CORS)。

关于node.js - PhoneJS w Ripple模拟器无法连接到本地 Node 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19249052/

相关文章:

javascript - 使用变量浏览 yaml 文件

node.js - 如何立即关闭 Node.js http(s) 服务器?

node.js - 使用nodejs在mongoDB oplog集合中查找每个新文档不起作用(光标似乎变得无效或死了)

mongodb - mongod 主进程被 KILL 信号杀死

javascript - 检查数组是否包含 mongodb 文档中的帖子 id

android - listView 中的波纹效果

javascript - Nodejs 每次响应发送多个文件

JavaScript NodeJs - 如何重构这一点

android - 自定义 View 中的涟漪效果

cordova - 如何检测我的应用程序是否在 Ripple Emulator 上运行?