Next.js Discord

Discord Forum

500 error on production home page - local it is working

Answered
Yacare Caiman posted this in #help-forum
Open in Discord
Yacare CaimanOP
I'm just started with Next.js and i am building a simple webpage with Next.js and Storyblok as its headless CMS. Deploying with Netlify.

In local it is all working but when i want to deploy it i don't get any errors when building (npm) and only the homepage is not working... every others pages with an other path then the homepage is working.
This is my getStaticProps() and getStaticPaths():
export async function getStaticProps({ params }) {
    let slug = params?.slug ? params.slug.join("/") : "home";

    let sbParams = {
        version: "draft", // or 'published'
    };

    const storyblokApi = getStoryblokApi();
    let { data } = await storyblokApi.get(`cdn/stories/${slug}`, sbParams);

    return {
        props: {
            story: data ? data.story : false,
            key: data ? data.story.id : false,
        },
        revalidate: 3600,
    };
}

export async function getStaticPaths() {
    const storyblokApi = getStoryblokApi();
    let { data } = await storyblokApi.get("cdn/links/");

    let paths = [];

    Object.keys(data.links).forEach((linkKey) => {
        if (data.links[linkKey].is_folder || data.links[linkKey].slug === "home") {
            return;
        }

        const slug = data.links[linkKey].slug;
        let splittedSlug = slug.split("/");

        paths.push({ params: { slug: splittedSlug } });
    });

    return {
        paths: paths,
        fallback: false,
    };
}
Answered by Ray
have you tried to deploy it on vercel? and does it work?
View full answer

17 Replies

Yacare CaimanOP
Does anyone know what this can be?
@Yacare Caiman Does anyone know what this can be?
have you checked the log on netlify?
@Ray have you checked the log on netlify?
Yacare CaimanOP
It's bit weird but when i go to logs on netlify i don't see any?
I see only one about: Function Next.js SSR handler
But when i check furthur, it says no results
have you tried to deploy it on vercel? and does it work?
Answer
Yacare CaimanOP
I will try, haven't used vercel before. Do you like it more?
vercel has the best support for nextjs
Yacare CaimanOP
Great will do it right now and let you know!
OK
@Ray OK
Yacare CaimanOP
Yes its working trough there!
Bit weird that it is not working with Netlify but with Vercel it does?
@Yacare Caiman Bit weird that it is not working with Netlify but with Vercel it does?
as I know netlify is not 100% fully support for nextjs
I think you have to report/ask them
Yacare CaimanOP
Thanks - i will do!
Maybe i will just use vercel in the future... 🙂
please mark solution if your issue has been solved