Skip to content

Commit

Permalink
fix(next-sample): fix undefined in getServerSideProps
Browse files Browse the repository at this point in the history
  • Loading branch information
wangsijie committed Oct 26, 2022
1 parent 6fb22ea commit acdbd00
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/next-sample/pages/profile-ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ 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;
res.end();
}

return {
props: { user },
props: { user: { isAuthenticated, claims } },
};
});
5 changes: 2 additions & 3 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
});
}
Expand Down

0 comments on commit acdbd00

Please sign in to comment.