From 8ae2441ba4e24493981ca623c2e78d302028e3e4 Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Thu, 27 Jul 2023 16:46:58 +0100 Subject: [PATCH 1/2] Update EXAMPLES.md Fix server side app router example --- EXAMPLES.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index f211b8236..135167d29 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -176,9 +176,10 @@ Requests to `/pages/profile` without a valid session cookie will be redirected t ```jsx // app/profile/page.js -import { withPageAuthRequired } from '@auth0/nextjs-auth0'; +import { withPageAuthRequired, getSession } from '@auth0/nextjs-auth0'; -export default withPageAuthRequired(function Profile({ user }) { +export default withPageAuthRequired(function Profile() { + const { user } = await getSession(); return
Hello {user.name}
; }, { returnTo: '/profile' }) // You need to provide a `returnTo` since Server Components aren't aware of the page's URL From 3569868b48acbad26cac136d61326b8b5838d34b Mon Sep 17 00:00:00 2001 From: Adam Mcgrath Date: Thu, 27 Jul 2023 16:48:33 +0100 Subject: [PATCH 2/2] Update EXAMPLES.md --- EXAMPLES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 135167d29..dace3fd3a 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -178,7 +178,7 @@ Requests to `/pages/profile` without a valid session cookie will be redirected t // app/profile/page.js import { withPageAuthRequired, getSession } from '@auth0/nextjs-auth0'; -export default withPageAuthRequired(function Profile() { +export default withPageAuthRequired(async function Profile() { const { user } = await getSession(); return
Hello {user.name}
; }, { returnTo: '/profile' })