fix: skip JSON body parsing for filebrowser upload routes

express.json() middleware was consuming the binary file body before the
upload handler could drain it, causing 404/parse errors on file uploads.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dorian 2026-03-09 21:27:26 +00:00
parent 7aa59d8072
commit dbd4cf59d2

View File

@ -40,7 +40,13 @@ const corsOptions = {
}
app.use(cors(corsOptions))
app.use(express.json({ limit: '50mb' }))
// Skip JSON body parsing for filebrowser upload routes (binary file bodies)
app.use((req, res, next) => {
if (req.path.startsWith('/app/filebrowser/api/resources') && req.method === 'POST') {
return next()
}
express.json({ limit: '50mb' })(req, res, next)
})
app.use(cookieParser())
// Mock session storage