Skip to content

Commit

Permalink
Merge pull request react-keycloak#171 from bring2dip/patch-1
Browse files Browse the repository at this point in the history
Readme example code improvements for SSR
  • Loading branch information
panz3r authored Dec 18, 2021
2 parents b976116 + 6fb4a56 commit f2d1594
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,14 @@ function MyApp({ Component, pageProps, cookies }: AppProps & InitialProps) {
)
}

function parseCookies(req?: IncomingMessage) {
if (!req || !req.headers) {
return {}
}
function parseCookies(req: IncomingMessage) {
return cookie.parse(req.headers.cookie || '')
}

MyApp.getInitialProps = async (context: AppContext) => {
// Extract cookies from AppContext
return {
cookies: parseCookies(context?.ctx?.req),
cookies: context.ctx.req ? parseCookies(context.ctx.req) : {},
}
}

Expand Down

0 comments on commit f2d1594

Please sign in to comment.