node.js - 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);
});```
解决方案
推荐阅读
- python - 将函数应用于 Dask DataFrame 组
- regex - Ruby 空字符串正则表达式
- sql-server - 减去 SUM 的耗尽和限制
- r - r 散点图和回归线问题
- java - 在 CoordinatorLayout 中禁用 AppBarLayout 时 RecyclerView 滚动故障?
- css - 放大时保持整个页面(水平滚动条位置)居中
- c++ - 在没有 UB 的情况下使用 [base+index*scale] 寻址两个不相关的数组
- swift - 如何从模型中获取数据并更新它
- sql - SQL将covid患者分配到医院
- javascript - 我的 javascript 函数无法正常工作