Source: pages/index.js

  1. /** @module pages */
  2. import { getAuthProps } from "../lib/auth";
  3. import Invite from "../containers/invite";
  4. import { getUserAgentProps } from "../lib/user-agent";
  5. import { serverSideTranslations } from "next-i18next/serverSideTranslations";
  6. /**
  7. * The home page and landing page. This page is only accessible for logged out users.
  8. */
  9. export default function Home(props) {
  10. const { deviceType } = props;
  11. return <Invite deviceType={deviceType} />;
  12. }
  13. export async function getServerSideProps(context) {
  14. const authProps = await getAuthProps(context);
  15. if (authProps?.props?.serverSession) {
  16. const { res } = context;
  17. res.setHeader("location", `/${context.locale}/dreams`);
  18. res.statusCode = 302;
  19. res.end();
  20. }
  21. return {
  22. props: {
  23. ...getUserAgentProps(context),
  24. ...(await serverSideTranslations(context.locale, [
  25. "layout",
  26. "footer",
  27. "editor",
  28. "common",
  29. ])),
  30. },
  31. };
  32. }