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
I am using Hono in an Astro project having Astro's middleware.ts which defines few props in Astro.locals. I am using @astrojs/cloudflare adapter to deploy it as Workers.
What is the recommended way to pass Astro's context to hono so that I can access it's props or call methods?
Here is my current code: src/pages/[...path].ts:
importappfrom'@/server';exportconstprerender=false;exportconstALL=(context)=>/* How can we pass the context *//* Is it convenient to pass it as second argument? */app.fetch(context.request,/* Workers bindings */context.locals.runtime.env,/* Workers execution context */context.locals.runtime.ctx);
src/server/index.ts:
import{Hono}from"hono";constapp=newHono().get("/hello",(c)=>{// How can we access Astro.rewrite(), Astro.locals[prop]// If c.env was set to Astro context, we need to use c.env.locals.runtime.env to access environment variables :/returnc.text("hello");});exportdefaultapp;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using Hono in an Astro project having Astro's middleware.ts which defines few props in Astro.locals. I am using
@astrojs/cloudflareadapter to deploy it as Workers.What is the recommended way to pass Astro's context to hono so that I can access it's props or call methods?
Here is my current code:
src/pages/[...path].ts:src/server/index.ts:Beta Was this translation helpful? Give feedback.
All reactions