Currently I’m trying to add a 404 handler to an ACE based app:
app.use((req, res, next) => {
res.status(404);
res.send("404 not found");
});
However that 404 handler interferes with serving atlassian-connect.json (i.e. does not get served anymore and gives a 404). I’ve put this 404 after routes(app, addon);.
Any experience or hints implementing a 404 handler with ACE?
Hi @david2 ,
Yes, it’s at the end of the app configuration.
The problem is, as soon as I add the 404 handler, the route /atlassian-connect.json isn’t served anymore.
I don’t know what I miss.
Do you have a 404 handler in your addon?
Actually no, we don’t.
Worst case, you can check if the request is for your app descriptor (either “/” or “/atlassian-connect.json”) and just call next() in that case.
I’ve checked ace code and they use process.nextTick to handle atlassian-connect.json route request. That means their code applies after yours and your 404 works before.