Skip to content

Commit bae5790

Browse files
Fix API boot crash: WebDAV HEAD route collided with Fastify's auto-HEAD
Fastify auto-generates a HEAD route from every GET route, so registering HEAD explicitly threw FST_ERR_DUPLICATED_ROUTE at startup — the API never came up, surfacing as a 502 behind nginx. Drop the explicit HEAD route; the auto-HEAD reuses the same handler (which special-cases HEAD). Verified by actually booting the server (app.ready + inject): OPTIONS/PROPFIND/HEAD on /dav and GET /health all respond instead of crashing.
1 parent 1ed24de commit bae5790

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎apps/api/src/routes/webdav.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ export const webdavRoutes: FastifyPluginAsync = async (app) => {
279279
const methods = [
280280
'OPTIONS',
281281
'GET',
282-
'HEAD',
283282
'PUT',
284283
'DELETE',
285284
'PROPFIND',
@@ -291,6 +290,9 @@ export const webdavRoutes: FastifyPluginAsync = async (app) => {
291290
'UNLOCK',
292291
];
293292
for (const method of methods) {
293+
// HEAD is intentionally omitted: Fastify auto-creates a HEAD route from each GET route and
294+
// reuses this handler (which special-cases method === 'HEAD'). Registering HEAD explicitly
295+
// would collide with that auto route (FST_ERR_DUPLICATED_ROUTE on boot).
294296
app.route({ method: method as never, url: '/', handler: handle });
295297
app.route({ method: method as never, url: '/*', handler: handle });
296298
}

0 commit comments

Comments
 (0)