Skip to content

Instantly share code, notes, and snippets.

@clovisdasilvaneto
Created August 20, 2021 22:17
Show Gist options
  • Save clovisdasilvaneto/e2d9c16d6cf4f4e45cf0a8803dba89f0 to your computer and use it in GitHub Desktop.
Save clovisdasilvaneto/e2d9c16d6cf4f4e45cf0a8803dba89f0 to your computer and use it in GitHub Desktop.
export const withCookies = (handler) => {
return async ({ req, ...ctx }) => {
const cookies = req?.headers?.cookies || null
try {
const SSRHandlerData = await handler({req, ...ctx})
return {
...SSRHandlerData,
props: {
...SSRHandlerData.props,
cookies
}
}
}catch(err) {
console.log(err)
throw new Error("Error while passing the cookies to the SSR handler")
}
}
}
export const getServerCookies =
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment