You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
848 B
JavaScript

import React from "react"
import PropTypes from "prop-types"
5 years ago
import axios from 'axios'
import Header from '~/components/header'
import Footer from '~/components/footer'
import "../styles/layout.css"
Layout.getInitialProps = async ({Component, ctx}) => {
// Configure axios instance
ctx.axios = axios.create({
headers: ctx.req ? {cookie: ctx.req.headers.cookie} : undefined
})
const {data: user} = await ctx.axios.get(`/api/auth`)
let pageProps = {};
if(Component.getInitialProps)
pageProps = await Component.getInitialProps({ctx})
return {pageProps, user}
5 years ago
}
5 years ago
function Layout({ Component, pageProps, user }){
return (
<>
5 years ago
<Header user={user} />
<main><Component {...{user, ...pageProps}} /></main>
<Footer/>
</>
)
}
Layout.propTypes = {
pageProps: PropTypes.object
}
export default Layout