summaryrefslogtreecommitdiffstats
path: root/frontend/pages
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-05-16 12:27:21 -0400
committerWes Bos <wesbos@gmail.com>2018-05-16 12:27:21 -0400
commit18752008f9abd7749f61f8d674f66de2a535c131 (patch)
tree5825328e58cf8a4a196532f8b40d515b185cd8ea /frontend/pages
parent802b65cfd634305f62d88cb57c54f8c053701d27 (diff)
SSR with Auth
Diffstat (limited to 'frontend/pages')
-rw-r--r--frontend/pages/_app.js5
-rw-r--r--frontend/pages/me.js5
2 files changed, 6 insertions, 4 deletions
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 = () => (
<>
<h2>My Account</h2>
- <EditUser />
+ <PleaseSignIn>
+ <EditUser />
+ </PleaseSignIn>
</>
);