首页 > 解决方案 > Express 端点超时

问题描述

我正在尝试让我的应用程序运行一个小型 API。我希望能够验证已经在 localhost 上运行的证书,如下所示:

localhost:3000/verify/asd-> 将查找 ID 为“asd”的任何证书并返回它或包含错误代码的对象。

但是当使用procfile将它部署到heroku时: web: node igdaapi.js每当我尝试这样做时都会超时domain:PORT/verify/asd

我正在尝试在带有原始 html 内容的 wordpress 页面上运行它。在本地尝试所有内容时,我尝试使用的 html 可以正常工作,但是当将其上传到 wordpress 然后将其部署到 heroku 时,它就无法正常工作。

这是代码:

const { find_certificate_in_db, generate_certificate_pdf } = require('./igdabot_general/general_certif_commands');
var app = express();

app.use(express.static("public"))

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
    console.log(`Our app is running on port ${ PORT }`);
});

app.get('/verify/:id', async function (req, res) {
    let cert_id = req.params.id;
    console.log("Hello, we need to verify", cert_id);
    certObject = await find_certificate_in_db(cert_id);

    console.log("Certification object: ");

    res.send(certObject);
});```

标签: node.jsexpresstimeout

解决方案


推荐阅读