-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
expose event.clientAddress
#4289
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
Changes from all commits
aa2c66a
58b13eb
2060a7e
32bfba3
0946d98
8eeaf36
42cf1ff
4fb6010
7aca944
874be1c
181bf2b
bbf862c
1fa6823
669b9f2
e5475bc
a548fa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@sveltejs/adapter-cloudflare': patch | ||
'@sveltejs/adapter-cloudflare-workers': patch | ||
'@sveltejs/adapter-netlify': patch | ||
'@sveltejs/adapter-node': patch | ||
'@sveltejs/adapter-vercel': patch | ||
--- | ||
|
||
Provide getClientAddress function |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
[breaking] require adapters to supply a getClientAddress function |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
expose client IP address as event.clientAddress |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,12 @@ export function init(manifest) { | |
const server = new Server(manifest); | ||
|
||
return async (event, context) => { | ||
const rendered = await server.respond(to_request(event), { platform: { context } }); | ||
const rendered = await server.respond(to_request(event), { | ||
platform: { context }, | ||
getClientAddress() { | ||
return event.headers['x-nf-client-connection-ip']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ascorbic I wanted to confirm with you if we're doing this correctly because it seems to be undocumented, but is what is suggested in this support post: https://answers.netlify.com/t/is-the-client-ip-header-going-to-be-supported-long-term/11203 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @benmccann Yes, that's correct. We recently cleaned up the internal headers sent to functions so that all remaining ones are now officially supported. https://answers.netlify.com/t/upcoming-change-stripping-exposed-netlify-headers-from-function-and-proxy-requests/52665 |
||
} | ||
}); | ||
|
||
const partial_response = { | ||
statusCode: rendered.status, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ascorbic I wanted to confirm with you if we're doing this correctly because it seems to be undocumented, but is what is suggested in this support post: https://answers.netlify.com/t/is-the-client-ip-header-going-to-be-supported-long-term/11203