Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Feature/subscription 75 ] 구독 & 구독 취소 API 연결 #78

Merged
merged 11 commits into from
Jun 27, 2024
8 changes: 7 additions & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export default function middleware(req: NextRequest) {
const nextUrl = req.nextUrl.clone();
const email = nextUrl.searchParams.get("user");

/** /workbook 으로 진입 시 리다이랙션 */
if (nextUrl.pathname === "/workbook") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 구조분해 할당하면 pathname으로도 가져올수있겟네요

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c74e82c

사용해봤습니다..!

nextUrl.pathname = "/workbook/1";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

나중에는 다른 workbook 페이지가 될수도 있을것같습니다...!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞아요!! 이 부분은 한 번 말해봐야겠네용!!

return NextResponse.redirect(nextUrl);
}

if (email) {
nextUrl.searchParams.delete("user");
const decodedEmail = decodeURIComponent(email);
Expand All @@ -39,5 +45,5 @@ export default function middleware(req: NextRequest) {
}

export const config = {
matcher: ["/unsubscribe/:path*"],
matcher: ["/unsubscribe/:path*", "/workbook/:path*"],
};