Voglio build API tramite node.js è normale lavoro in locale, ma fallisce nel cloud. puoi aiutarmi a trovare l'errore? grazieNode.js build json api per heroku
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
});
registri
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 [email protected]
2014-11-26T03:30:55.675999+00:00 heroku[api]: Release v16 created by [email protected]
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
come tronchi, aggiungo stato e cambiare per
res.status(200).json
ancora non funziona, prega di aiuto, grazie
rimuovo vista (.ejs) e mostrare JSON solo, funziona! Ma ancora non so come risolvere il problema della vista. –
Stai usando la sintassi corretta per opentok? Guardando questo link 'https://tokbox.com/opentok/tutorials/create-session/node/'it sembra che usano la funzione' opentok.createSession() 'invece della funzione' .generateToken() 'che sei utilizzando. Se funziona localmente e non nel cloud, puoi confermare che stai utilizzando la stessa versione di questo modulo sia sul cloud che localmente? – MonsterWimp757
No, local è lo stesso problema, e ho solo bisogno del json back, quindi rimuovo il caricamento front-end, grazie per la risposta –