Skip to content

Conversation

@huseeiin
Copy link
Contributor

add more ip support :)

@huseeiin huseeiin requested a review from pi0 as a code owner January 15, 2026 15:16
@vercel
Copy link

vercel bot commented Jan 15, 2026

@huseeiin is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

📝 Walkthrough

Walkthrough

Updates add client IP extraction and runtime initialization across Netlify, Vercel (Node & Web), and Cloudflare presets; Netlify handler signature tightened to ServerRequest and ISR/context access adjusted.

Changes

Cohort / File(s) Summary
Netlify runtime
src/presets/netlify/runtime/netlify.ts
Handler signature changed to async (req: ServerRequest). Ensures req.runtime = { name: "netlify" } when missing, sets req.ip from x-nf-client-connection-ip, and reads ISR options from req.context.
Vercel runtimes
src/presets/vercel/runtime/vercel.node.ts, src/presets/vercel/runtime/vercel.web.ts
Node: overrides req.socket.remoteAddress via Object.defineProperty, sourcing IP from x-forwarded-for. Web: initializes full req.runtime = { name: "vercel", vercel: { context } } and defines lazy req.ip that reads x-forwarded-for.
Cloudflare runtime
src/presets/cloudflare/runtime/_module-handler.ts
augmentReq now assigns req.ip from the cf-connecting-ip header (or undefined if absent) before further request augmentation.
Manifests / metadata
manifest_file, package.json
Minor manifest/package metadata edits (few lines changed).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows conventional commits format with scope (vercel, netlify, cloudflare) and clear description of the feature being added (req.ip support).
Description check ✅ Passed The description relates to the changeset by indicating the PR adds IP support, which aligns with the file changes adding req.ip properties across multiple platforms.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 15, 2026

Open in StackBlitz

npm i https://pkg.pr.new/nitrojs/nitro@3952

commit: c058924

@pi0 pi0 changed the title add netlify & vercel ip support feat(vercel, netlify): support req.ip Jan 20, 2026
) {
// replace req.socket.remoteAddress with x-forwarded-for because req.socket.remoteAddress is not accurate and req.socket.remoteAddress is how the srvx node adapter reads the ip. this is subject to debate
Object.defineProperty(req.socket, "remoteAddress", {
value: req.headers["x-forwarded-for"],
Copy link
Member

@pi0 pi0 Jan 20, 2026

Choose a reason for hiding this comment

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

/cc @QuiiBz do you think of any better way for Node.js style handler? (can't we rely on original remoteAddress? i see it is currently always 127.0.0.1)

@pi0 pi0 mentioned this pull request Jan 20, 2026
8 tasks
@pi0 pi0 changed the title feat(vercel, netlify): support req.ip feat(vercel, netlify, cloudflare): support req.ip Jan 20, 2026
@pi0 pi0 merged commit 74e8d67 into nitrojs:main Jan 20, 2026
10 of 11 checks passed
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