turt2live / matrix-dimension

An open source integration manager for matrix clients, like Element.
https://dimension.t2bot.io
GNU General Public License v3.0
431 stars 110 forks source link

Headers already sent #442

Open nosshar opened 2 years ago

nosshar commented 2 years ago

This fallback route fires on each request: https://github.com/turt2live/matrix-dimension/blob/147a53640225ff3d34b1ab3ce367cd8c9b06eaf7/src/api/Webserver.ts#L43

It can be rewritten as:

this.app.get(/(widgets\/|riot\/|element\/|\/)*/, (_req, res) => {
    if (!res.headersSent) {
        res.sendFile(path.join(__dirname, "..", "..", "web", "index.html"));
    }
});

There is no need to return the contents of index.html if something hadled the request earlier. Not an experienced user of ExpressJS though, but got application working (stikcers at least) without annoying error.