Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.

Commit 41d7d09

Browse files
committed
로그아웃 status code를 200으로 변경
1 parent 8144603 commit 41d7d09

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

packages/react-contexts/src/session-context/browser.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,23 @@ export function InBrowserSessionContextProvider({
5151
}, [])
5252

5353
const logout = useCallback<SessionControllers['logout']>(async () => {
54-
const response = await authGuardedFetchers.put('/api/users/logout')
54+
const response = await authGuardedFetchers.put<{ redirectUrl: string }>(
55+
'/api/users/logout',
56+
)
5557

5658
clearUserState()
5759

5860
if (response === 'NEED_LOGIN') {
5961
return
6062
}
6163

62-
if (response.status === 301 || response.status === 302) {
63-
const redirectLocation = response.headers.get('Location')
64+
const isNolConnectedUser =
65+
response.ok &&
66+
response.status === 200 &&
67+
!!response.parsedBody.redirectUrl
68+
69+
if (isNolConnectedUser) {
70+
const redirectLocation = response.parsedBody.redirectUrl
6471

6572
if (!redirectLocation) {
6673
captureHttpError(response)
@@ -71,6 +78,7 @@ export function InBrowserSessionContextProvider({
7178
const redirectUrl = getRedirectUrl(redirectLocation)
7279

7380
window.location.href = redirectUrl
81+
return
7482
}
7583

7684
window.location.reload()

packages/react-contexts/src/session-context/redirect.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('getRedirectUrl', () => {
1010
it('should return redirect url with redirect query string', () => {
1111
const result = getRedirectUrl('https://example.com')
1212
expect(result).toBe(
13-
`https://example.com?redirect=${encodeURIComponent(
13+
`https://example.com?redirectUrl=${encodeURIComponent(
1414
window.location.href,
1515
)}`,
1616
)
@@ -19,7 +19,7 @@ describe('getRedirectUrl', () => {
1919
it('should return redirect url with redirect query string and original href query string', () => {
2020
const result = getRedirectUrl('https://example.com?code=123')
2121
expect(result).toBe(
22-
`https://example.com?code=123&redirect=${encodeURIComponent(
22+
`https://example.com?code=123&redirectUrl=${encodeURIComponent(
2323
window.location.href,
2424
)}`,
2525
)

packages/react-contexts/src/session-context/redirect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function getRedirectUrl(href: string) {
77
const redirectUrl = generateUrl(
88
{
99
query: qs.stringify({
10-
redirect: currentUrl,
10+
redirectUrl: currentUrl,
1111
}),
1212
},
1313
href,

0 commit comments

Comments
 (0)