fixed 404 error

This commit is contained in:
Ludwig Lehnert
2026-01-29 07:15:55 +01:00
parent 6eb42cd223
commit 4b7f48d782

View File

@@ -1613,7 +1613,6 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
<div class="muted">Noch ${formatCountdown(item.expires_at)}</div>
</td>
<td class="actions">
<button type="button" class="secondary copy-link" data-path="${fileHref}">Link kopieren</button>
<form method="post" action="${baseUrl(`/files/${item.id}/delete`)}">
${csrfField(res.locals.csrfToken)}
<button type="submit" class="secondary">Löschen</button>
@@ -1624,6 +1623,9 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
<button type="submit">Verlängern</button>
</form>
</td>
<td>
<button type="button" class="secondary copy-link" data-path="${fileHref}">Link kopieren</button>
</td>
</tr>
`;
}).join('');
@@ -1668,6 +1670,7 @@ app.get(`${basePath}/dashboard`, requireAuthPage, async (req, res) => {
<th>Größe</th>
<th>Läuft ab</th>
<th>Aktionen</th>
<th>Link</th>
</tr>
</thead>
<tbody>
@@ -1830,12 +1833,6 @@ app.post(`${basePath}/files/:id/extend`, requireAuthPage, async (req, res) => {
res.redirect(baseUrl('/dashboard'));
});
app.use((req, res) => {
res.status(404).send(renderPage('Nicht gefunden', '<p class="card">Seite nicht gefunden.</p>'));
});
// Add endpoint to serve files with correct headers
// NOTE: This must be mounted at root level or matching the path prefix handled by Traefik
app.get('/_share/:filename', async (req, res) => {
const filename = req.params.filename;
// Security check: ensure no path traversal
@@ -1860,6 +1857,10 @@ app.get('/_share/:filename', async (req, res) => {
res.download(row.stored_path, row.original_name);
});
app.use((req, res) => {
res.status(404).send(renderPage('Nicht gefunden', '<p class="card">Seite nicht gefunden.</p>'));
});
const server = app.listen(port, () => {
console.log(`Express server listening on ${port} with base path ${basePath}`);
});