Skip to content

Commit a93d7ff

Browse files
committed
fix: handle 404 on unknown routes
1 parent b028cfd commit a93d7ff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/index.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ export default {
7979
const overrides = Object.fromEntries(ctx.url.searchParams.entries());
8080
ctx.config = await resolveConfig(ctx, overrides);
8181

82-
console.debug('resolved config: ', JSON.stringify(ctx.config));
82+
console.debug('resolved config: ', JSON.stringify(ctx.config, null, 2));
8383
if (!ctx.config) {
8484
return errorResponse(404, 'config not found');
8585
}
8686

87-
return await handlers[ctx.config.route](ctx, request);
87+
const fn = handlers[ctx.config.route];
88+
if (!fn) {
89+
return errorResponse(404, 'route not found');
90+
}
91+
return await fn(ctx, request);
8892
} catch (e) {
8993
if (e.response) {
9094
return e.response;

0 commit comments

Comments
 (0)