File tree Expand file tree Collapse file tree 3 files changed +8
-7
lines changed
Expand file tree Collapse file tree 3 files changed +8
-7
lines changed Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server'
22
3+ import { HTTPError } from 'ky'
4+
35import { backendApi } from '@/services/api'
46
57const BACKEND_BASE_URL = process . env . NEXT_PUBLIC_BACKEND_BASE_URL
@@ -12,10 +14,9 @@ export const POST = async (req: Request): Promise<NextResponse> => {
1214 . post ( 'refresh' , { json : { refreshToken } } )
1315 . json < { accessToken : string } > ( )
1416 return NextResponse . json ( { success : true , accessToken } )
15- } catch ( error : any ) {
17+ } catch ( error : unknown ) {
1618 console . error ( 'ํ ํฐ ๊ฐฑ์ ์๋ฌ:' , error )
17-
18- if ( error . response ) {
19+ if ( error instanceof HTTPError ) {
1920 const errorData = await error . response . json ( )
2021 return NextResponse . json (
2122 {
@@ -25,7 +26,6 @@ export const POST = async (req: Request): Promise<NextResponse> => {
2526 { status : error . response . status }
2627 )
2728 }
28-
2929 return NextResponse . json (
3030 { success : false , message : 'Internal server error' } ,
3131 { status : 500 }
Original file line number Diff line number Diff line change 11import { NextResponse } from 'next/server'
22
33import { SignInRequest , SignInResponse } from '@/types/api/auth.types'
4+ import { HTTPError } from 'ky'
45
56import { backendApi } from '@/services/api'
67
@@ -33,10 +34,10 @@ export const POST = async (req: Request): Promise<NextResponse> => {
3334 } )
3435
3536 return res
36- } catch ( error : any ) {
37+ } catch ( error : unknown ) {
3738 console . error ( 'Login failed:' , error )
3839
39- if ( error . response ) {
40+ if ( error instanceof HTTPError ) {
4041 const errorData = await error . response . json ( )
4142 return NextResponse . json (
4243 { error : errorData . message || 'Login failed' } ,
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export async function middleware(
4646 } )
4747
4848 return res
49- } catch ( error : any ) {
49+ } catch ( error : unknown ) {
5050 console . error ( '์์ธ์ค ํ ํฐ ๊ฐฑ์ ์คํจ' , error )
5151 return NextResponse . redirect ( new URL ( '/sign-in' , req . url ) )
5252 }
You canโt perform that action at this time.
0 commit comments