trying a different redirect for home to event-types

pull/403/head
Peer Richelsen 2021-08-02 20:04:06 +02:00
parent 9051a0d60e
commit 71fc0ba437
1 changed files with 17 additions and 14 deletions

View File

@ -1,16 +1,19 @@
export default function Home() {
return (
<div className="loader">
<span className="loader-inner"></span>
</div>
);
import { useRouter } from "next/router";
function RedirectPage() {
const router = useRouter();
if (typeof window !== "undefined") {
router.push("/event-types");
return;
}
}
export async function getStaticProps() {
return {
redirect: {
destination: "/event-types",
permanent: false,
},
};
}
RedirectPage.getInitialProps = (ctx) => {
if (ctx.res) {
ctx.res.writeHead(302, { Location: "/event-types" });
ctx.res.end();
}
return {};
};
export default RedirectPage;