fix: clientAddress undefined in production server functions (nitro-v2)#2122
Draft
fix: clientAddress undefined in production server functions (nitro-v2)#2122
Conversation
|
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
2 tasks
… v2 handler Agent-Logs-Url: https://github.com/solidjs/solid-start/sessions/88adfed3-e429-4cbb-801c-3c8a91c3f8d5 Co-authored-by: brenelz <184235+brenelz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix undefined client address in server functions
fix: clientAddress undefined in production server functions (nitro-v2)
Mar 28, 2026
Contributor
|
I think we are probably deprecating "nitro-v2" plugin soon so this might not be needed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getRequestEvent().clientAddressreturnsundefinedin production when using@solidjs/vite-plugin-nitro-2, despite working in dev.Root Cause
The virtual entry bridging Nitro (h3 v1) → solid-start (h3 v2) was:
Three things combine to drop the IP:
fromWebHandlercallshandler(toWebRequest(event), event.context)—toWebRequestproduces a plainRequestwith no IP metadataH3Core.fetch(request)ignores the second argument, so the context is never passed throughgetRequestIPchecksevent.req.context?.clientAddressandevent.req.ip— bothundefinedon the converted requestFix
Replace the
fromWebHandlershorthand with an expliciteventHandlerthat extracts the IP from the outer Nitro h3 v1 event and attaches it torequest.contextbefore callinghandler.fetch:h3 v2's
H3Eventconstructor readsreq.contextas the event context, sogetRequestIPsubsequently findsevent.req.context.clientAddress. The socket-based IP is tried first;xForwardedForis used as fallback for reverse-proxy deployments.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.