Skip to content

Commit f128579

Browse files
Merge pull request #41 from 9git9git/hotfix
[HOTFIX ] schedule 동적렌더링으로 수정
2 parents 0b3845b + cf78390 commit f128579

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

actions/user.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use server';
22

33
import { cookies } from 'next/headers';
4+
import { redirect } from 'next/navigation';
45

56
export async function getUser() {
67
try {
@@ -17,6 +18,10 @@ export async function getUser() {
1718
);
1819
const data = await result.json();
1920

21+
if (!data.data) {
22+
redirect('/login');
23+
}
24+
2025
const userResponse = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/users/${data.data.sub}`, {
2126
method: 'GET',
2227
headers: {

app/(service)/schedule/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { Schedule } from '@/components/service/schedule/Schedule';
22

3+
export const dynamic = 'force-dynamic';
4+
35
export default function SchedulePage() {
46
return <Schedule />;
57
}

components/service/schedule/Schedule.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getTodAndMemoList } from '@/apis/todo';
66
import { getUser } from '@/actions/user';
77
import { Suspense } from 'react';
88
import { getCategoryItems } from '@/apis/category';
9-
9+
import { redirect } from 'next/navigation';
1010
export const Schedule = async () => {
1111
const user = await getUser();
1212
const { todos, memos } = await getTodAndMemoList({
@@ -15,6 +15,10 @@ export const Schedule = async () => {
1515
endDate: '2030-12-31',
1616
});
1717

18+
if (!user) {
19+
redirect('/login');
20+
}
21+
1822
const categoryItems = await getCategoryItems();
1923

2024
return (

0 commit comments

Comments
 (0)