Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: node middleware #725

Merged
merged 16 commits into from
Feb 27, 2025
Merged

Conversation

conico974
Copy link
Contributor

@conico974 conico974 commented Feb 5, 2025

This should be close to being ready

Couple of issues that needed to be resolved:

Copy link

changeset-bot bot commented Feb 5, 2025

🦋 Changeset detected

Latest commit: a863666

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

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Minor
app-pages-router Patch
app-router 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

Copy link

pkg-pr-new bot commented Feb 5, 2025

Open in Stackblitz

pnpm add https://pkg.pr.new/@opennextjs/aws@725

commit: a863666

@sommeeeer
Copy link
Contributor

sommeeeer commented Feb 7, 2025

great work on this Nico!

one thing to note; Node.js middleware in next dev is not supported with turbopack yet if anyone wonders, which is partially why this is still in experimental.

options,
);

// Do we need to copy or do something with env file here?
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I'm not sure. I can't think of anything obvious.

Copy link
Contributor

@khuezy khuezy left a comment

Choose a reason for hiding this comment

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

Nice LGTM!

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM.

One thing I did not realize is that Node and edge middlewares are exclusive.

Added a few minor comments.

@@ -50,7 +50,7 @@ export async function compileOpenNextConfig(
// We need to check if the config uses the edge runtime at any point
// If it does, we need to compile it with the edge runtime
const usesEdgeRuntime =
config.middleware?.external ||
(config.middleware?.external && config.middleware.runtime !== "node") ||
Copy link
Contributor

Choose a reason for hiding this comment

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

comment: this might not play well with Cloudflare but we probably need to rethink how we compile to edge vs node

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i think we should rely on the wrapper to tell us how we should compile (i.e. node vs workers).
For the moment i think it's fine, node middleware is still experimental

@conico974 conico974 force-pushed the feat/node-middleware branch from 413f661 to a863666 Compare February 27, 2025 15:33
@conico974 conico974 merged commit 096c273 into opennextjs:main Feb 27, 2025
3 checks passed
@github-actions github-actions bot mentioned this pull request Feb 27, 2025
@conico974 conico974 deleted the feat/node-middleware branch March 14, 2025 12:44
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.

4 participants