-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from Moaguide-develop/dev
Dev
- Loading branch information
Showing
7 changed files
with
80 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
import { usePathname, useRouter } from 'next/navigation'; | ||
import { getCookie } from '@/utils/cookie'; | ||
|
||
const GnbWrapper = () => { | ||
const pathname = usePathname(); | ||
const router = useRouter(); | ||
const token = getCookie('access_token'); | ||
useEffect(() => { | ||
if ( | ||
!token && | ||
pathname !== '/sign' && | ||
pathname !== '/signin' && | ||
pathname !== '/signup' && | ||
pathname !== '/find' && | ||
// pathname !== '/search' && | ||
pathname !== '/' | ||
) { | ||
alert('로그인이 필요한 서비스입니다.'); | ||
router.replace('/sign'); | ||
} | ||
}, [router, pathname, token]); | ||
|
||
return null; | ||
}; | ||
|
||
export default GnbWrapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { NextResponse } from 'next/server'; | ||
import type { NextRequest } from 'next/server'; | ||
import { cookies } from 'next/headers'; | ||
|
||
export function middleware(request: NextRequest) { | ||
// const getCookie = (key: string) => { | ||
// return cookies().get(key)?.value; | ||
// }; | ||
|
||
// const token = getCookie('access_token'); | ||
// const pathname = request.nextUrl.pathname; | ||
|
||
// const dynamicRouteRegex = /^\/product\/detail\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/; | ||
// if (!token && dynamicRouteRegex.test(pathname)) { | ||
// console.log('Dynamic route detected:', pathname); | ||
// return NextResponse.redirect(new URL('/sign', request.url)); | ||
// } | ||
// if ( | ||
// pathname.startsWith('/api') || | ||
// pathname.includes('.') || | ||
// pathname.startsWith('/_next/static/') || | ||
// pathname.startsWith('/favicon') || | ||
// pathname === '/manifest.json' || | ||
// pathname.startsWith('/icons/') | ||
// ) { | ||
// return NextResponse.next(); | ||
// } | ||
// console.log('middleware full URL:', request.nextUrl.href); | ||
// if ( | ||
// !token && | ||
// !['/sign', '/signin', '/signup', '/find', '/search', '/'].includes(pathname) | ||
// ) { | ||
// return NextResponse.redirect(new URL('/sign', request.url)); | ||
// } | ||
|
||
return NextResponse.next(); | ||
} |