nextjs Data List
- NEXT.JS 기본개념
- NEXT.JS 설치
- NEXT.JS 실행방법
- NEXT.JS 파일 및 구조
- NEXT.JS 데이터 가져오기
- NEXT.JS API 쿼리데이터 생성
- NEXT.JS Components
- NEXT.JS page.js 파라미터 처리
- NEXT.JS app router 방식 client ip 주소 가져오는 방법
- NEXT.JS monaco-editor 사용방법
- NEXT.JS react-quill 사용방법
- NEXT.JS app router 방식 rss feed.xml 간단하게 설정 방법
- NEXT.JS app router 방식 sitemap.xml 간단하게 설정 방법
NEXT.JS app router 방식 client ip 주소 가져오는 방법
2023-11-30 09:47:00
/ 목차 /
- 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