Skip to content
Discussion options

You must be logged in to vote

Appearantly it is possible, but it is required to use the following vite module for dev:

import { NitroApp } from "nitropack";
import { defineNitroPlugin } from "nitropack/dist/runtime/plugin";

export default defineNitroPlugin((nitroApp: NitroApp) => {
  nitroApp.hooks.hook("request", async (event) => {
    const _pkg = "wrangler"; // Bypass bundling!
    const { getPlatformProxy } = (await import(
      _pkg
    )) as typeof import("wrangler");
    const platform = await getPlatformProxy();

    event.context.cf = platform["cf"];
    event.context.cloudflare = {
      env: platform["env"] as unknown as Env,
      context: platform["ctx"],
    };
  });
});

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@MrStickyPiston
Comment options

Comment options

You must be logged in to vote
2 replies
@brandonroberts
Comment options

@MrStickyPiston
Comment options

Answer selected by MrStickyPiston
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants