I am facing a potential bug that I had not experienced before:
When I create a document of any custom type (I have tried two differents custom type, same bug), I am able to create, click on publish, and preview the created document that has been published.
However, when I remove the "preview" and try to access the same URL in real production, I am experiencing an 404 error.
Would anybody be kind as helping me please?
Here's the codee in _app.js:
import Head from "next/head";
import "../styles/globals.css";
import Layout from "../components/layout/Layout";
import { config } from "@fortawesome/fontawesome-svg-core";
import "@fortawesome/fontawesome-svg-core/styles.css";
config.autoAddCss = false;
import { SessionProvider } from "next-auth/react";
import { useSession } from "next-auth/react";
import Link from "next/link";
import { PrismicProvider } from "@prismicio/react";
import { PrismicPreview } from "@prismicio/next";
import { dataaijobs } from "../prismicio";
import { useRouter } from "next/router";
// import { QueryClient, QueryClientProvider } from "react-query";
function MyApp({ Component, pageProps }) {
const router = useRouter();
const canonicalUrl = (
`https://dataai-jobs.com` + (router.asPath === "/" ? "" : router.asPath)
).split("?")[0];
return (
// <QueryClientProvider client={queryClient}>
<PrismicProvider
internalLinkComponent={({ href, ...props }) => (
<Link href={href}>
<a {...props} />
</Link>
)}
>
<SessionProvider session={pageProps.session}>
<Layout>
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
<link rel="icon" type="image/png" href="/images/favicon-daj.png" />
<link rel="canonical" href={canonicalUrl} />
</Head>
<PrismicPreview repositoryName={dataaijobs}>
{Component.auth ? (
<Auth>
<Component {...pageProps} />
</Auth>
) : (
<Component {...pageProps} />
)}
</PrismicPreview>
</Layout>
</SessionProvider>
</PrismicProvider>
// </QueryClientProvider>
);
}
// Client side protection authentification through component:
function Auth({ children }) {
const { status } = useSession({ required: true });
// when `required: true` is passed,
// `status` can only be "loading" or "authenticated"
if (status === "loading") {
return <div>Loading...</div>;
}
return children;
}
export default MyApp;
Hello @Marving, thanks for reaching out.
Which URL are you trying to access, is this document published and accessible in the production version of your site?
Have you tried testing the entire pages in development mode?
Maybe the project isn't building correctly, and the changes are only in the API still but arent' rendered in the front-end.