File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
apps/webapp/app/routes/login.magic Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,8 @@ export async function action({ request }: ActionFunctionArgs) {
105
105
}
106
106
107
107
const { email } = data ;
108
- const clientIp = request . headers . get ( "x-forwarded-for" ) ;
108
+ const xff = request . headers . get ( "x-forwarded-for" ) ;
109
+ const clientIp = extractClientIp ( xff ) ;
109
110
110
111
const [ error ] = await tryCatch (
111
112
Promise . all ( [
@@ -168,6 +169,13 @@ export async function action({ request }: ActionFunctionArgs) {
168
169
}
169
170
}
170
171
172
+ const extractClientIp = ( xff : string | null ) => {
173
+ if ( ! xff ) return null ;
174
+
175
+ const parts = xff . split ( "," ) . map ( ( p ) => p . trim ( ) ) ;
176
+ return parts [ parts . length - 1 ] ; // take last item, ALB appends the real client IP by default
177
+ } ;
178
+
171
179
export default function LoginMagicLinkPage ( ) {
172
180
const { magicLinkSent, magicLinkError } = useTypedLoaderData < typeof loader > ( ) ;
173
181
const navigate = useNavigation ( ) ;
You can’t perform that action at this time.
0 commit comments