File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ const API_BASE_URL = 'https://gdgocinha.site/auth'; // 프록시 대상 주소
55
66export async function POST ( req ) {
77 const targetUrl = `${ API_BASE_URL } /refresh` ;
8+ const isProd = process . env . NODE_ENV === 'production' ;
89
910 try {
1011 const cookies = req . headers . get ( 'cookie' ) || '' ;
@@ -33,8 +34,8 @@ export async function POST(req) {
3334 nextResponse . cookies . set ( name , value , {
3435 path : '/' ,
3536 httpOnly : true ,
36- secure : process . env . NODE_ENV === 'production' ,
37- sameSite : 'strict ',
37+ secure : isProd ,
38+ sameSite : isProd ? 'none' : 'lax ',
3839 } ) ;
3940 } ) ;
4041 }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export async function POST(request) {
77 try {
88 // 클라이언트로부터 받은 요청 데이터 추출
99 const { email, password } = await request . json ( ) ;
10+ const isProd = process . env . NODE_ENV === 'production' ;
1011
1112 // gdgocinha.site/auth/login으로 요청 전달
1213 const response = await axios . post (
@@ -30,18 +31,18 @@ export async function POST(request) {
3031 // 원본 응답의 쿠키가 있으면 추출하여 현재 도메인에 설정
3132 const cookies = response . headers [ 'set-cookie' ] ;
3233 if ( cookies ) {
33- cookies . forEach ( cookie => {
34+ cookies . forEach ( ( cookie ) => {
3435 // 쿠키 문자열에서 이름과 값 부분만 추출
3536 const cookieParts = cookie . split ( ';' ) [ 0 ] . split ( '=' ) ;
3637 const cookieName = cookieParts [ 0 ] ;
3738 const cookieValue = cookieParts . slice ( 1 ) . join ( '=' ) ;
38-
39+
3940 // 추출한 쿠키를 현재 도메인에 설정
4041 nextResponse . cookies . set ( cookieName , cookieValue , {
4142 path : '/' ,
4243 httpOnly : true ,
43- secure : process . env . NODE_ENV === 'production' ,
44- sameSite : 'strict ',
44+ secure : isProd ,
45+ sameSite : isProd ? 'none' : 'lax ',
4546 } ) ;
4647 } ) ;
4748 }
You can’t perform that action at this time.
0 commit comments