I'm creating a REST app that posts 2 images (base64 strings) for comparing using Resemble js. In my local, when I spin up the server and test using postman
, it works fine. I deployed the same code to Heroku
and test the heroku endpoint with the same data, it is throwing me an error.
Here is my code.
const express = require('express');
const app = express();
let port = process.env.PORT || 3000;
const bodyParser = require('body-parser');
const resemble = require("resemblejs");
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.send('Hello World!!');
})
app.post('/', (req, res) => {
console.log(req.body);
var src = req.body.src;
var dest = req.body.dest;
resemble(src).compareTo(
dest
).ignoreColors().onComplete(data => {
console.log(JSON.stringify(data));
res.send(JSON.stringify(data));
}).catch(err => {
console.log(err);
});
})
app.listen(port, () => {
console.log(`Listening on port ${port}`);
})
You can test the api here.
The error I get when I looked at the heroku logs by using the command heroku logs --tail --app resemble-js-sf
2021-01-24T09:11:37.128025+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-24T09:11:41.023786+00:00 heroku[web.1]: Starting process with command `node index.js`
2021-01-24T09:11:43.522499+00:00 app[web.1]: internal/modules/cjs/loader.js:1057
2021-01-24T09:11:43.522520+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
2021-01-24T09:11:43.522521+00:00 app[web.1]: ^
2021-01-24T09:11:43.522521+00:00 app[web.1]:
2021-01-24T09:11:43.522522+00:00 app[web.1]: Error: /app/node_modules/canvas/build/Release/canvas.node: invalid ELF header
2021-01-24T09:11:43.522522+00:00 app[web.1]: at Object.Module._extensions..node (internal/modules/cjs/loader.js:1057:18)
2021-01-24T09:11:43.522522+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-24T09:11:43.522523+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-24T09:11:43.522523+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:887:19)
2021-01-24T09:11:43.522523+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:74:18)
2021-01-24T09:11:43.522524+00:00 app[web.1]: at Object.<anonymous> (/app/node_modules/canvas/lib/bindings.js:3:18)
2021-01-24T09:11:43.522524+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:999:30)
2021-01-24T09:11:43.522524+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
2021-01-24T09:11:43.522525+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:863:32)
2021-01-24T09:11:43.522525+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:708:14)
2021-01-24T09:11:43.574021+00:00 heroku[web.1]: Process exited with status 1
2021-01-24T09:11:43.616109+00:00 heroku[web.1]: State changed from starting to crashed
2021-01-24T10:12:33.734281+00:00 heroku[web.1]: State changed from crashed to starting
2021-01-24T10:12:36.481044+00:00 heroku[web.1]: Starting process with command `node index.js`
2021-01-24T10:12:39.939626+00:00 app[web.1]: internal/modules/cjs/loader.js:1057
2021-01-24T10:12:39.939641+00:00 app[web.1]: return process.dlopen(module, path.toNamespacedPath(filename));
Please let me know where am I going wrong and how can I fix it?
question from:
https://stackoverflow.com/questions/65871698/simple-rest-app-working-in-local-but-not-in-heroku 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…