-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth client/#62 #75
Auth client/#62 #75
Changes from all commits
93e5118
7206911
70e5a45
8823521
b5bdc13
5e0da04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
import Link from 'next/link'; | ||
|
||
export default function Error({ error, reset }: { error: Error; reset: () => void }) { | ||
useEffect(() => { | ||
console.error(error); | ||
}, [error]); | ||
|
||
if (error.message === 'Unauthorized') { | ||
return ( | ||
<div> | ||
<h2>Unauthorized</h2> | ||
<Link href="/sign-in">to Login</Link> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div> | ||
<h2>Something went wrong!!!!!</h2> | ||
<button | ||
onClick={ | ||
// μΈκ·Έλ¨ΌνΈλ₯Ό μ¬ λ λλ§ νμ¬ λ³΅κ΅¬λ₯Ό μλν©λλ€. | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</div> | ||
); | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ν΄λΉ νμ΄μ§λ μΈμ νΈμΆμ΄ λκ³ μ΄λ μν μ νλμ§ μΆκ°λ‘ μ€λͺ μ ν΄μ£Όμ€ μ μμκΉμ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ λ κΆκΈν©λλ€ ! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { API_PATH } from '@/app/business/api-path'; | ||
import { httpErrorHandler } from '@/app/utils/http/http-error-handler'; | ||
|
||
async function trigger() { | ||
const response = await fetch(`${API_PATH.auth}/failure`, { | ||
cache: 'no-store', | ||
}); | ||
const result = await response.json(); | ||
httpErrorHandler(response, result); | ||
} | ||
|
||
export default async function ProtectedPage() { | ||
const data = await trigger(); | ||
return <div>Auth protected</div>; | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. global-errorλ νλ‘λμ μμλ§ νμ±νλμ΄ sub-pageμ errorμμ ν΄λΉ μ²λ¦¬λ₯Ό μ§ννλ κ²μΌλ‘ μ΄ν΄νλλ°, ν΄λΉ νμΌμ μ΄λ»κ² μ¬μ©λ μμ μΈκ°μ? μΆν λ³κ²½μ μμνμλμ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use client'; | ||
import { useEffect } from 'react'; | ||
|
||
// https://nextjs.org/docs/app/building-your-application/routing/error-handling#handling-errors-in-root-layouts | ||
// global-errorλ νλ‘λμ μμλ§ νμ±ν | ||
export default function GlobalError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) { | ||
useEffect(() => { | ||
// Log the error to an error reporting service | ||
console.error(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html> | ||
<body> | ||
<h2>Something went wrong!!!!!</h2> | ||
<button | ||
onClick={ | ||
// μΈκ·Έλ¨ΌνΈλ₯Ό μ¬ λ λλ§ νμ¬ λ³΅κ΅¬λ₯Ό μλν©λλ€. | ||
() => reset() | ||
} | ||
> | ||
Try again | ||
</button> | ||
</body> | ||
</html> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageλ‘ κ΅¬λΆμ νλλ°, λ°±μλμμ μλ¬ μ messageλ₯Ό 보λ΄μ£Όκ³ μμ§ μμ μνμ λλ€.
μ΄μ λν΄μ λ°±μλνν μ¬μμ²μ ν κΉμ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.