diff --git a/components/Header/Header.tsx b/components/Header/Header.tsx index 1d8d161..13d44d1 100644 --- a/components/Header/Header.tsx +++ b/components/Header/Header.tsx @@ -2,7 +2,7 @@ import React, { useState } from "react"; import styled from "styled-components"; import Head from "next/head"; import { useRouter } from "next/router"; -import { useSession, signIn, signOut, getSession } from "next-auth/react"; +import { useSession, signIn, signOut } from "next-auth/react"; import Cookies from "js-cookie"; import LogoutIcon from "@mui/icons-material/Logout"; import { GitSt } from "@services/gitstory"; @@ -17,7 +17,6 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p const [openApiPopup, setOpenApiPopup] = React.useState(false); const router = useRouter(); - const slug = router.query.slug || []; const handleHeaderSearchTextChange = (e) => { let parsedValues = e.target.value.split("/"); @@ -41,8 +40,7 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p } async function saveGitHubSessionToCookie() { - const sessionInfo = await getSession(); - sessionInfo ? Cookies.set("github_at", sessionInfo.accessToken) : Cookies.remove("github_at"); + session ? Cookies.set("github_at", session.accessToken) : Cookies.remove("github_at"); } const keyPress = (e) => { @@ -95,25 +93,26 @@ export default function Header({ withLeftPart = true, withPaddings = false, ...p {/* SEO */} - + + + - + - + - - + + - + - {/* SEO */} @@ -216,4 +215,3 @@ const LeftWrapper: any = styled.div` margin-top: 5px; } `; - diff --git a/next.config.js b/next.config.js index d1c4169..2249ddb 100644 --- a/next.config.js +++ b/next.config.js @@ -7,5 +7,6 @@ module.exports = { // This is the default value, but we want to be explicit GITHUB_SECRET: process.env.GITHUB_SECRET, GITHUB_ID: process.env.GITHUB_ID, + WEBSITE_HOST: process.env.WEBSITE_HOST, }, }; diff --git a/pages/_document.tsx b/pages/_document.tsx new file mode 100644 index 0000000..8cbf096 --- /dev/null +++ b/pages/_document.tsx @@ -0,0 +1,24 @@ +import Document, { DocumentContext } from "next/document"; +import { ServerStyleSheet } from "styled-components"; + +export default class MyDocument extends Document { + static async getInitialProps(ctx: DocumentContext) { + const sheet = new ServerStyleSheet(); + const originalRenderPage = ctx.renderPage; + + try { + ctx.renderPage = () => + originalRenderPage({ + enhanceApp: (App) => (props) => sheet.collectStyles(), + }); + + const initialProps = await Document.getInitialProps(ctx); + return { + ...initialProps, + styles: [initialProps.styles, sheet.getStyleElement()], + }; + } finally { + sheet.seal(); + } + } +}