Skip to content

Commit 17dd513

Browse files
committed
빌드 시 DynamicServerError 뜨는거 해결
1 parent 001899d commit 17dd513

11 files changed

+38
-14
lines changed

src/app/lib/delete-account.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import {cookies} from "next/headers";
44

55
export async function deleteAccount(initialState: any, formData: FormData) {
6+
const sessionCookieValue = cookies().get('session')?.value
7+
68
const res = await fetch('http://localhost:8000/account', {
79
method: 'DELETE',
810
cache: 'no-store',
911
headers: {
1012
'Accept': 'application/json',
1113
'Content-Type': 'application/json',
12-
'Authorization': `Bearer ${cookies().get('session')?.value}`
14+
'Authorization': `Bearer ${sessionCookieValue}`
1315
},
1416
body: JSON.stringify({
1517
password: formData.get('password')?.toString()

src/app/lib/email-change-verification.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import {cookies} from "next/headers";
44

55
export async function emailChangeVerification(initialState: any, formData: FormData) {
6+
const sessionToken = cookies().get('session')?.value
67
try {
78
const res = await fetch('http://localhost:8000/account/email-verification', {
89
method: 'POST',
910
cache: 'no-store',
1011
headers: {
1112
'Accept': 'application/json',
1213
'Content-Type': 'application/json',
13-
'Authorization': `Bearer ${cookies().get('session')?.value}`
14+
'Authorization': `Bearer ${sessionToken}`
1415
},
1516
body: JSON.stringify({
1617
code: formData.get('code')?.toString(),

src/app/lib/email-verification.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import {redirect} from "next/navigation";
44
import {cookies} from "next/headers";
55

66
export async function emailVerification(initialState: any, formData: FormData) {
7+
const sessionToken = cookies().get('session')?.value
78
try {
89
const res = await fetch('http://localhost:8000/account/email-verification', {
910
method: 'POST',
1011
cache: 'no-store',
1112
headers: {
1213
'Accept': 'application/json',
1314
'Content-Type': 'application/json',
14-
'Authorization': `Bearer ${cookies().get('session')?.value}`
15+
'Authorization': `Bearer ${sessionToken}`
1516
},
1617
body: JSON.stringify({
1718
code: formData.get('code')?.toString(),

src/app/lib/get-recommend-history.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {RecommendHistoryElement} from "@/app/types/recommend-history-element";
55
import {notFound} from "next/navigation";
66

77
export async function getRecommendHistory(cursorId?: number): Promise<RecommendHistoryElement[]> {
8+
const sessionToken = cookies().get('session')?.value
9+
810
let url = 'http://localhost:8000/account/recommend-history'
911

1012
if (cursorId !== undefined) {
@@ -14,7 +16,7 @@ export async function getRecommendHistory(cursorId?: number): Promise<RecommendH
1416
const res = await fetch(url, {
1517
cache: 'no-store',
1618
headers: {
17-
'Authorization': `Bearer ${cookies().get('session')?.value}`
19+
'Authorization': `Bearer ${sessionToken}`
1820
}
1921
})
2022

src/app/lib/get-survey-result.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ export async function getSurveyResult(answer: Array<any>) {
1414
'Content-Type': 'application/json',
1515
}
1616

17-
if (cookies().has('session'))
18-
headers.Authorization = `Bearer ${cookies().get('session')?.value}`;
17+
if (cookies().has('session')) {
18+
const sessionToken = cookies().get('session')?.value
19+
headers.Authorization = `Bearer ${sessionToken}`;
20+
}
1921

2022
const res = await fetch('http://localhost:8000/survey', {
2123
method: 'POST',

src/app/lib/get-userinfo.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import {cookies} from "next/headers";
22
import type {AccountInfo} from "@/app/types/account-info";
33

44
export async function getUserInfo(): Promise<AccountInfo|null|-1> {
5+
const sessionToken = cookies().get('session')?.value
6+
7+
const authorization = "Bearer " + sessionToken
8+
59
try {
610
const res = await fetch('http://localhost:8000/account', {
711
cache: 'no-store',
812
headers: {
9-
authorization: `Bearer ${cookies().get('session')?.value}`
13+
authorization: authorization
1014
}
1115
})
1216

src/app/lib/isLoggedIn.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
import {cookies} from "next/headers";
44

55
export async function isLoggedIn () {
6-
if (cookies().has('session')) {
6+
const hasSession = cookies().has('session')
7+
8+
if (hasSession) {
9+
const sessionToken = cookies().get('session')?.value
10+
711
const res = await fetch('http://localhost:8000/account', {
812
cache: 'no-store',
913
headers: {
10-
authorization: `Bearer ${cookies().get('session')?.value}`
14+
authorization: `Bearer ${sessionToken}`
1115
}
1216
})
1317

src/app/lib/password-change.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import {cookies} from "next/headers";
44

55
export async function passwordChange(prevState: any, formData: FormData) {
6+
const sessionToken = cookies().get('session')?.value
7+
68
const res = await fetch('http://localhost:8000/account/password', {
79
method: 'PATCH',
810
cache: 'no-store',
911
headers: {
1012
'Accept': 'application/json',
1113
'Content-Type': 'application/json',
12-
'authorization': `Bearer ${cookies().get('session')?.value}`
14+
'authorization': `Bearer ${sessionToken}`
1315
},
1416
body: JSON.stringify({
1517
password: formData.get('password')?.toString(),

src/app/lib/request-email-change.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
import {cookies} from "next/headers";
44

55
export async function requestEmailChange(password: string, newEmail: string):Promise<true|number> {
6+
const sessionToken = cookies().get('session')?.value
7+
68
const res = await fetch('http://localhost:8000/account/email', {
79
method: 'PATCH',
810
cache: 'no-store',
911
headers: {
1012
'Accept': 'application/json',
1113
'Content-Type': 'application/json',
12-
'Authorization': `Bearer ${cookies().get('session')?.value}`
14+
'Authorization': `Bearer ${sessionToken}`
1315
},
1416
body: JSON.stringify({
1517
password: password,

src/app/lib/verification-email-resend.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import {cookies} from "next/headers";
44

55
export async function verificationEmailResend() {
6-
const res = await fetch('http://localhost:8000/account/verification-mail-resend', {
6+
const sessionToken = cookies().get('session')?.value
7+
8+
await fetch('http://localhost:8000/account/verification-mail-resend', {
79
cache: 'no-store',
810
headers: {
9-
'Authorization': `Bearer ${cookies().get('session')?.value}`
11+
'Authorization': `Bearer ${sessionToken}`
1012
}
1113
})
1214
}

0 commit comments

Comments
 (0)