Node.js为heroku构buildjson api
我想通过node.js构buildAPI,这在本地是正常工作,但在云中失败。 你能帮我findbug吗? 谢谢
https://infinite-gorge-6020.herokuapp.com
app.get('/', function(req, res) { res.render('index.ejs'); }); app.get('/host', function(req, res) { var sessionId = app.get('sessionId'), // generate a fresh token for this client token = opentok.generateToken(sessionId, { role: 'moderator' }); res.json('host.ejs', { apiKey: apiKey, sessionId: sessionId, token: token });
日志
2014-11-26T03:25:38.289313+00:00 heroku[router]: at=info method=GET path="/css/sample.css" host=infinite-gorge-6020.herokuapp.com request_id=18d8ce80-53a3-487f-94f5-a45f984bad67 fwd="1.171.57.36" dyno=web.1 connect=4ms service=6ms status=200 bytes=720 2014-11-26T03:25:39.207199+00:00 heroku[router]: http_error="Invalid HTTP status line" at=error code=H17 desc="Poorly formatted HTTP response" method=GET path="/host" host=infinite-gorge-6020.herokuapp.com request_id=a56aaf2e-7d2b-4479-bc01-3efd9542432b fwd="1.171.57.36" dyno=web.1 connect=1ms service=3ms status=503 bytes=639 2014-11-26T03:30:50+00:00 heroku[slug-compiler]: Slug compilation started 2014-11-26T03:30:55+00:00 heroku[slug-compiler]: Slug compilation finished 2014-11-26T03:30:55.675999+00:00 heroku[api]: Deploy cd3d6fe by kenshin0812@hotmail.com 2014-11-26T03:30:55.675999+00:00 heroku[api]: Release v16 created by kenshin0812@hotmail.com 2014-11-26T03:30:55.943650+00:00 heroku[web.1]: State changed from up to starting 2014-11-26T03:30:57.789085+00:00 heroku[web.1]: Starting process with command `node index.js` 2014-11-26T03:30:58.927452+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2014-11-26T03:30:59.218593+00:00 heroku[web.1]: State changed from starting to up 2014-11-26T03:30:59.079473+00:00 app[web.1]: Listening on , server_port 14730 2014-11-26T03:31:00.557311+00:00 heroku[web.1]: Process exited with status 143 2014-11-26T03:31:06.268233+00:00 heroku[router]: at=info method=GET path="/" host=infinite-gorge-6020.herokuapp.com request_id=824385d9-4aa9-439d-86a4-e8693d080e6b fwd="1.171.57.36" dyno=web.1 connect=1ms service=46ms status=200 bytes=2770 2014-11-26T03:31:06.529761+00:00 heroku[router]: at=info method=GET path="/css/sample.css" host=infinite-gorge-6020.herokuapp.com request_id=1f19e9ee-008f-4a33-b66a-bbd7f6b75bea fwd="1.171.57.36" dyno=web.1 connect=5ms service=9ms status=200 bytes=720 2014-11-26T03:31:08.043604+00:00 heroku[router]: http_error="Invalid HTTP status line" at=error code=H17 desc="Poorly formatted HTTP response" method=GET path="/host" host=infinite-gorge-6020.herokuapp.com request_id=bd19cbbe-bc58-4d4c-8426-d016e29555e1 fwd="1.171.57.36" dyno=web.1 connect=1ms service=6ms status=503 bytes=635 2014-11-26T03:31:08.041211+00:00 app[web.1]: Wed, 26 Nov 2014 03:31:08 GMT express deprecated res.json(status, obj): Use res.status(status).json(obj) instead at index.js:43:7
作为日志,我添加状态,并改变
res.status(200).json
还是不行,请帮忙,谢谢
res.json([body])
发送一个JSON响应。 当传递一个对象或数组时,此方法与res.send()完全相同。
res.json(null) res.json({ user: 'tobi' }) res.status(500).json({ error: 'message' })
对于一个json API服务,你可能不需要渲染任何东西。
res.json只需要一个对象,只要删除'host.ejs',
res.json({ apiKey: apiKey, sessionId: sessionId, token: token });
- Node.js /socket.io/socket.io.js找不到4.0
- 获取TypeError:在Backbone.js中创build集合时,d.collection是未定义的错误
- 使用Node + Jade + Express渲染存储在Mongo(GridFS)中的图像
- 使用passport.js和express.js(node.js)创build安全的oauth API
- 使用Node / Express将HTML5 Canvas上传到Azure
- 在本地MongoDB点mongoos.connect
- 使用$ .get定期轮询Express服务器
- 无法通过浏览器访问mongodb – 它看起来像试图通过本地驱动程序端口上的HTTP访问MongoDB
- 用多个字段表示app.get