get user ip in trpc

I know https://www.answeroverflow.com/m/1097080265928609802 in here the question is already answered but i get value in ip as ::ffff:127.0.0.1 this instead of real ip

here is how I do that
export const createTRPCContext = async (opts: CreateNextContextOptions) => {
    const { req, res } = opts

    let ip = req.headers['x-forwarded-for'] as string
    const session = await getServerAuthSession({ req, res })

    return createInnerTRPCContext({
        session,
        ip
    })
}


and when I make request I receive in response that ::ffff:127.0.0.1

thats testing response
 .mutation(async ({ ctx }) => {    
   return { success: true, ip: ctx.ip }
 })
Was this page helpful?