Skip to content

Conversation

vicb
Copy link
Contributor

@vicb vicb commented Apr 10, 2025

I have been willing to do this for a long time...

The init code does not belong to the server bundle, it can be used for i.e. an external middleware.

Further benefits:

  • We now have a way to inject values a build time via ESBuild defines, that will be useful for basePath support
  • It will make it easier to add other entry points (scheduled, ...)

@changeset-bot
Copy link

changeset-bot bot commented Apr 10, 2025

🦋 Changeset detected

Latest commit: 9fff83d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Apr 10, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/cloudflare@563

commit: 9fff83d

@vicb vicb requested review from conico974 and james-elicx April 10, 2025 13:02
Copy link
Collaborator

@conico974 conico974 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one small comment

Object.assign(globalThis, {
Request: CustomRequest,
// This is only needed for an external middleware bundle
__dangerous_ON_edge_converter_returns_request: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add that actually for an external middleware ? This means that the output of the middleware will be a Request.
It's fine when everything was in 1 worker, but if we have multiple worker it won't work as expected (or it will require a custom converter/wrapper to forward the request)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, I'll remove this.
Thanks for catching that.

@vicb vicb merged commit 2ce6454 into main Apr 10, 2025
7 checks passed
@vicb vicb deleted the vicb/init branch April 10, 2025 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants