From 18752008f9abd7749f61f8d674f66de2a535c131 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Wed, 16 May 2018 12:27:21 -0400 Subject: SSR with Auth --- frontend/pages/_app.js | 5 ++--- frontend/pages/me.js | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'frontend/pages') diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index 742532f..b2f67cb 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -17,13 +17,12 @@ class MyApp extends App { // } // } static async getInitialProps({ Component, ctx }) { + let pageProps = {}; if (!process.browser && ctx.req.headers.cookie) { // if we are SSR, pass along the cookie to apollo - console.log('On the server'); const cookies = cookie.parse(ctx.req.headers.cookie); - console.log(cookies.token); + pageProps.token = cookies.token; } - let pageProps = {}; if (Component.getInitialProps) { pageProps = await Component.getInitialProps(ctx); diff --git a/frontend/pages/me.js b/frontend/pages/me.js index 1dca3e8..b0c2c25 100644 --- a/frontend/pages/me.js +++ b/frontend/pages/me.js @@ -1,9 +1,12 @@ import EditUser from '../components/EditUser'; +import PleaseSignIn from '../components/PleaseSignIn'; const MyAccount = () => ( <>

My Account

- + + + ); -- cgit v1.3