@cloudwerk/vite-plugin 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +16 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -557,6 +557,13 @@ app.use('*', async (c, next) => {
|
|
|
557
557
|
return
|
|
558
558
|
}
|
|
559
559
|
|
|
560
|
+
// Skip static asset serving during SSG \u2014 the ASSETS binding from getPlatformProxy
|
|
561
|
+
// is not a real Workers Static Assets binding and does not support fetch(Request)
|
|
562
|
+
if (c.env?.HONO_SSG_CONTEXT) {
|
|
563
|
+
await next()
|
|
564
|
+
return
|
|
565
|
+
}
|
|
566
|
+
|
|
560
567
|
// Only serve static assets for GET/HEAD requests
|
|
561
568
|
// Other methods (POST, PUT, etc.) should go directly to route handlers
|
|
562
569
|
// to avoid consuming the request body
|
|
@@ -567,7 +574,15 @@ app.use('*', async (c, next) => {
|
|
|
567
574
|
}
|
|
568
575
|
|
|
569
576
|
// Try to serve the request as a static asset
|
|
570
|
-
|
|
577
|
+
let response
|
|
578
|
+
try {
|
|
579
|
+
response = await c.env.ASSETS.fetch(c.req.raw)
|
|
580
|
+
} catch {
|
|
581
|
+
// ASSETS.fetch can fail during SSG or when the binding is a proxy
|
|
582
|
+
// that doesn't support fetch(Request) \u2014 fall through to routes
|
|
583
|
+
await next()
|
|
584
|
+
return
|
|
585
|
+
}
|
|
571
586
|
|
|
572
587
|
// If asset found (not 404), return it with cache headers
|
|
573
588
|
if (response.status !== 404) {
|