You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hono/cloudflare-pages currently provides a handle adapter to use hono with Pages Function, and a serveStatic adapter to handle static assets. It would be great if there was a similar adapter for Pages middleware.
My specific use-case is using HTMLRewriter to rewrite static assets based on the value of a cookie.
// functions/_middleware.tsimport{getCookie}from'hono/cookie'import{handleMiddleware}from'hono/cloudflare-pages'exportconstonRequest=handleMiddleware(async(c,next)=>{constmyCookie=getCookie(c,'my_cookie')constresponse=awaitnext()// Alternative API similar to Pages middlewareconstresponse=awaitc.next()returnnewHTMLRewriter().on('head',newInjectScriptHandler(myCookie)).transform(response)})
Let me know if this is worth adding, I'd be happy to contribute
The text was updated successfully, but these errors were encountered:
Cloudflare Pages has it's own concept for middleware functions
https://developers.cloudflare.com/pages/functions/middleware/
hono/cloudflare-pages
currently provides ahandle
adapter to use hono with Pages Function, and aserveStatic
adapter to handle static assets. It would be great if there was a similar adapter for Pages middleware.My specific use-case is using
HTMLRewriter
to rewrite static assets based on the value of a cookie.Let me know if this is worth adding, I'd be happy to contribute
The text was updated successfully, but these errors were encountered: