From 46bcae2b33fc4b8767fc587df1505667eabd134e Mon Sep 17 00:00:00 2001 From: Jaie Wilson Date: Mon, 9 Jan 2023 18:10:44 +1100 Subject: [PATCH] fix: getInitialProps not being called in the App https://github.com/instantcommerce/next-password-protect/issues/59 --- src/hoc/withPasswordProtect.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/hoc/withPasswordProtect.tsx b/src/hoc/withPasswordProtect.tsx index 113f3c8..98db01d 100644 --- a/src/hoc/withPasswordProtect.tsx +++ b/src/hoc/withPasswordProtect.tsx @@ -1,4 +1,5 @@ import React, { ElementType, useEffect, useState } from 'react'; +import { NextPageContext } from 'next'; import { useAmp } from 'next/amp'; import type { AppProps } from 'next/app'; @@ -74,6 +75,13 @@ export const withPasswordProtect = ( /> ); }; + ProtectedApp.getInitialProps = async (ctx: NextPageContext) => { + if (App.getInitialProps) { + return App.getInitialProps(ctx); + } + + return {}; + }; return ProtectedApp; };