From acdbd006cad94f73eefd3467723d8246be0a61fc Mon Sep 17 00:00:00 2001 From: wangsijie Date: Tue, 25 Oct 2022 14:11:25 +0800 Subject: [PATCH] fix(next-sample): fix undefined in getServerSideProps --- packages/next-sample/pages/profile-ssr.tsx | 5 +++-- packages/node/src/index.ts | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/next-sample/pages/profile-ssr.tsx b/packages/next-sample/pages/profile-ssr.tsx index 97d541fa6..6798038a6 100644 --- a/packages/next-sample/pages/profile-ssr.tsx +++ b/packages/next-sample/pages/profile-ssr.tsx @@ -50,8 +50,9 @@ export default ProfileSsr; export const getServerSideProps = logtoClient.withLogtoSsr(async function ({ req, res }) { const { user } = req; + const { claims, isAuthenticated } = user; - if (!user.isAuthenticated) { + if (!isAuthenticated) { res.setHeader('location', '/api/logto/login'); // eslint-disable-next-line @silverhand/fp/no-mutation res.statusCode = 302; @@ -59,6 +60,6 @@ export const getServerSideProps = logtoClient.withLogtoSsr(async function ({ req } return { - props: { user }, + props: { user: { isAuthenticated, claims } }, }; }); diff --git a/packages/node/src/index.ts b/packages/node/src/index.ts index 66b01ae1a..378a1e461 100644 --- a/packages/node/src/index.ts +++ b/packages/node/src/index.ts @@ -38,13 +38,12 @@ export default class LogtoClient extends BaseClient { return fetch(input, { ...init, headers: { - ...init?.headers, - - authorization: `basic ${Buffer.from( + Authorization: `basic ${Buffer.from( // eslint-disable-next-line @typescript-eslint/restrict-template-expressions `${config.appId}:${config.appSecret}`, 'utf8' ).toString('base64')}`, + ...init?.headers, }, }); }