fix: add catch-all S3 route for path-style requests (/{bucket}/{key})
Deploy FileDrop / deploy (push) Successful in 36s
Deploy FileDrop / deploy (push) Successful in 36s
Bun's '/' route only matches root path '/'. S3 SDK clients using
forcePathStyle:true send ALL requests to /{bucket}/{key} which never
matched any route → 404. Added '/*' catch-all that checks for S3
auth headers before dispatching.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,35 @@ export const routes = {
|
||||
POST: handleS3Direct,
|
||||
OPTIONS: handleS3Direct,
|
||||
},
|
||||
// Catch-all for S3 path-style requests (/{bucket}/{key} ...)
|
||||
// Only intercepts requests with S3 auth headers; others get 404.
|
||||
'/*': {
|
||||
GET: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
PUT: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
HEAD: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
DELETE: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
POST: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
PATCH: (req: Request): Promise<Response> => {
|
||||
if (shouldHandleS3(req, Object.fromEntries(req.headers))) return handleS3Direct(req);
|
||||
return Promise.resolve(new Response('Not Found', { status: 404 }));
|
||||
},
|
||||
OPTIONS: handleS3Direct,
|
||||
},
|
||||
'/api/v1/auth/login': {
|
||||
POST: withRateLimit(handleLogin),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user