File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { appFactory, triggerFactory } from '#src/helpers/factory.js'
33import { cookieSession } from '#src/middlewares/session.js'
44import { cors } from 'hono/cors'
55import { logger as loggerMiddleware } from 'hono/logger'
6- import { env } from 'std-env'
6+ import { env , isWorkerd } from 'std-env'
77import { apiApp } from './api/$'
88import { logger } from './helpers/logger'
99import { setupOpenAPI } from './openAPI'
@@ -14,7 +14,15 @@ export const app = appFactory.createApp()
1414 . use ( providersInit )
1515
1616 // Register global not found handler
17- . notFound ( c => c . text ( 'four-o-four' , 404 ) )
17+ . notFound ( ( c ) => {
18+ if ( c . req . path . startsWith ( '/api' ) )
19+ return c . text ( 'four-o-four' , 404 )
20+
21+ if ( isWorkerd )
22+ return c . env . ASSETS . fetch ( '/200.html' )
23+
24+ return c . text ( 'four-o-four' , 404 )
25+ } )
1826
1927 // Register global error handler
2028 . onError ( errorHandler )
Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ export interface HonoEnv {
77 Bindings : {
88 event : LambdaEvent
99 context : LambdaContext
10+
11+ /**
12+ * Cloudflare Workers binding
13+ */
14+ ASSETS : { fetch : ( reqOrUrl : Request | string ) => Promise < Response > }
1015 }
1116 Variables : {
1217 session : Session
You can’t perform that action at this time.
0 commit comments