Skip to content

[Bug?]: preserve original web RequestΒ #1879

@huseeiin

Description

@huseeiin

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

getRequestEvent()?.nativeEvent.web?.request.cf?.country

is undefined in wrangler pages dev dist because this isn't the original h3 web request which includes cf properties

Expected behavior πŸ€”

if you run this in cloudflare, you'll get a string:

import { createApp, toWebHandler } from "h3";

export default {
  fetch: toWebHandler(
    createApp().use("/", (e) => {
      return new Response(e.web?.request?.cf?.country);
    })
  ),
};

Steps to reproduce πŸ•Ή

see above

Context πŸ”¦

workaround is getRequestEvent()?.nativeEvent.context

Your environment 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions