File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import { memberRouter } from './backend/routers/member'
66import { handleCronJob } from './backend/services/cron'
77import { CloudflareBindings } from './backend/models/types'
88
9- const app = new Hono < { Bindings : CloudflareBindings } > ( )
9+ type Bindings = CloudflareBindings & {
10+ ASSETS : any // Cloudflare Assets binding
11+ }
12+
13+ const app = new Hono < { Bindings : Bindings } > ( )
1014
1115// API Routes
1216app . route ( '/api/auth' , authRouter )
@@ -20,6 +24,12 @@ frontendRoutes.forEach(route => {
2024 app . get ( route , renderer ) ;
2125} ) ;
2226
27+ // Handle static assets
28+ app . get ( '/client/*' , async ( c ) => {
29+ const assetPath = c . req . path . replace ( '/client' , '' )
30+ return c . env . ASSETS . fetch ( new Request ( `${ new URL ( c . req . url ) . origin } ${ assetPath } ` ) )
31+ } )
32+
2333// Catch-all route for client-side routing
2434app . get ( '*' , ( c ) => {
2535 const path = c . req . path
Original file line number Diff line number Diff line change 44 "compatibility_date" : " 2025-08-03" ,
55 "compatibility_flags" : [" nodejs_compat" ],
66 "main" : " ./src/backendMain.tsx" ,
7+ "assets" : {
8+ "directory" : " ./dist/client" ,
9+ "binding" : " ASSETS"
10+ },
711 "d1_databases" : [
812 {
913 "binding" : " DB" ,
You can’t perform that action at this time.
0 commit comments