File tree Expand file tree Collapse file tree 3 files changed +12
-1
lines changed
components/service/schedule Expand file tree Collapse file tree 3 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 11'use server' ;
22
33import { cookies } from 'next/headers' ;
4+ import { redirect } from 'next/navigation' ;
45
56export 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 : {
Original file line number Diff line number Diff line change 11import { Schedule } from '@/components/service/schedule/Schedule' ;
22
3+ export const dynamic = 'force-dynamic' ;
4+
35export default function SchedulePage ( ) {
46 return < Schedule /> ;
57}
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import { getTodAndMemoList } from '@/apis/todo';
66import { getUser } from '@/actions/user' ;
77import { Suspense } from 'react' ;
88import { getCategoryItems } from '@/apis/category' ;
9-
9+ import { redirect } from 'next/navigation' ;
1010export 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 (
You can’t perform that action at this time.
0 commit comments