404 handler for atlassian-connect-express

Currently I’m trying to add a 404 handler to an ACE based app:

app.use((req, res, next) => {
     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?

Did you put this at the end of your app configuration (after the other calls to app.use)?

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.

@david2 , sure I can do that, or write my own route for /atlassian-connect.json.

However I expect that there should be a best practice way for ACE.

@nmansilla can you help?