Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
don't rely on cookie-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
nickredmark committed Oct 22, 2018
1 parent 1e5d422 commit 5a5c90c
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions packages/ooth-client-react-next/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ import { composeInitialProps } from "compose-next";
import { OothClient, User } from "ooth-client";
import { OothProvider } from "ooth-client-react";

const stringifyCookies = (cookies: { [key: string]: string }) =>
Object.keys(cookies)
.map((key: string) => `${key}=${cookies[key]}`)
.join("; ");

export default (oothClient: OothClient) => {
class OothProviderWithInitialProps extends React.Component<{ initialUser: User | undefined; children: React.Component }> {
public static async getInitialProps(ctx: any): Promise<{ initialUser: User | undefined }> {
return {
initialUser: ctx.req
? await oothClient.fetchUser(ctx.req.cookies && { Cookie: stringifyCookies(ctx.req.cookies) })
? await oothClient.fetchUser(ctx.req.headers && { cookie: ctx.req.headers.cookie })
: await oothClient.start()
};
}
Expand Down

0 comments on commit 5a5c90c

Please sign in to comment.