nextjs Data List

/ 목차 /
- NEXT.JS app router 방식 client ip 주소 가져오는 방법
NEXT.JS app router 방식 client ip 주소 가져오는 방법
client ip주소가 headers에 값을 전달 받기때문에 import { headers } from 'next/headers' 추가하여 코드를 작성하면 됩니다.code import { headers } from 'next/headers' export default async function Ipconfig() { const header = headers() const ip = (header.get('x-forwarded-for') ?? '127.0.0.1').split(',')[0] return ( <> <div className="IPMainWrapper"> <div className="IPheader"> <h1>내 아이피 확인</h1> </div> <div className="IPmain"> <h2>{ip}</h2> </div> </div> </> ); }
Comment