SolidStart - Nitro Module missing `context` keys in `request`

Hey guys, I understand what I am asking about is likely out of scope, as this is dealing with a 3rd party package. However, with the stack I am unsure where to start asking questions. I'm seeing that SolidStart uses Vinxi + Nitro internally for the dev / build server. In order to better facilitate Cloudflare Pages local development, I've found the following package: nitro-cloudflare-dev, which is made for Nuxt and Nitro. Currently it seems Nitro does not natively support Worker bindings in local development, so this seems to be the next best thing. Thankfully, SolidStart's app.config.ts seems to expose Nitro config through the server: key, so I put modules: [nitroCloudflareBindings] in there to enable it. High level, the package seems to work by putting stuff into event.context.cloudflare. However, I'm seeing that when I try to make a middleware.ts for SolidStart, that event.context is not available. Instead, attempting to access event.nativeEvent.context does at least have a _nitro key in there, but nothing else. Also using the getEvent() from vinxi/server yields the same result - an empty .context key (except for _nitro). What can be done to resolve this? Perhaps the tool is now writing to the wrong key? Or perhaps Vinxi, Nitro, or Solid is dropping this .context.cloudflare key somewhere along the line? Thanks for any pointers!
1 Reply
Magnus
Magnus4mo ago
I have the same problem as you, I can´t access Cloudflare bindings in dev mode. I have also tried "nitro-cloudflare-dev", but the plugin does not run. Maybe plugins are not supported yet? Did you find a solution to this? Using getPlatformProxy() like in this example https://developers.cloudflare.com/workers/wrangler/api/#usage-1 does give access to the bindings.
import { getPlatformProxy } from "wrangler";

const { env } = await getPlatformProxy();
console.log(`MY_VARIABLE = ${env.MY_VARIABLE}`);
import { getPlatformProxy } from "wrangler";

const { env } = await getPlatformProxy();
console.log(`MY_VARIABLE = ${env.MY_VARIABLE}`);
Cloudflare Docs
API · Cloudflare Workers docs
A set of programmatic APIs that can be integrated with local Cloudflare Workers-related workflows.