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) {
105105 }
106106
107107 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 ) ;
109110
110111 const [ error ] = await tryCatch (
111112 Promise . all ( [
@@ -168,6 +169,13 @@ export async function action({ request }: ActionFunctionArgs) {
168169 }
169170}
170171
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+
171179export default function LoginMagicLinkPage ( ) {
172180 const { magicLinkSent, magicLinkError } = useTypedLoaderData < typeof loader > ( ) ;
173181 const navigate = useNavigation ( ) ;
You can’t perform that action at this time.
0 commit comments