1

I'm trying to deploy a Next application with Prismic and i'm getting this error in the building process. I have tried the solution with the webhook configuration in the Vercel servers without sucess Prismic Webhooks

Here is the [slug].tsx code:

export const getStaticPaths: GetStaticPaths = async () => {
    return {
        paths: [],
        fallback: 'blocking'
    }
}


export const getStaticProps: GetStaticProps = async ({ params }) => {
    const prismic = getPrismicClient()

    const { slug } = params;

    const response = await prismic.getByUID('post', String(slug), {})

    const post = {
        slug,
        title: RichText.asText(response.data.title),
        content: RichText.asHtml(response.data.content),
        updatedAt: new Date(response.last_publication_date).toLocaleDateString('pt-BR', {
            day: '2-digit',
            month: 'long',
            year: 'numeric'
        })
    };

    return {
        props: {
            post,
        },
        redirect: 60 * 60 * 24 * 7 //7 dias
    }
}

This is the prismic.ts file:

import Prismic from '@prismicio/client'

export function getPrismicClient(req?: unknown) {
    const prismic = Prismic.client(
        process.env.PRISMIC_ENDPOINT,
        {
            req,
            accessToken: process.env.PRISMIC_ACCESS_TOKEN
        }
    )
    
    return prismic;
}

Here is the error log from Vercel:

22:13:41.009    Error occurred prerendering page "/posts". Read more: https://nextjs.org/docs/messages/prerender-error
22:13:41.009    TypeError: Only absolute URLs are supported
22:13:41.010        at getNodeRequestOptions (/vercel/path0/node_modules/node-fetch/lib/index.js:1305:9)
22:13:41.010        at /vercel/path0/node_modules/node-fetch/lib/index.js:1410:19
22:13:41.010        at new Promise (<anonymous>)
22:13:41.010        at fetch (/vercel/path0/node_modules/node-fetch/lib/index.js:1407:9)
22:13:41.011        at fetch (/vercel/path0/node_modules/cross-fetch/dist/node-ponyfill.js:10:20)
22:13:41.011        at fetchRequest (/vercel/path0/node_modules/@prismicio/client/cjs/@prismicio/client.js:989:24)
22:13:41.011        at DefaultRequestHandler.request (/vercel/path0/node_modules/@prismicio/client/cjs/@prismicio/client.js:1026:9)
22:13:41.011        at HttpClient.request (/vercel/path0/node_modules/@prismicio/client/cjs/@prismicio/client.js:1037:29)
22:13:41.011        at /vercel/path0/node_modules/@prismicio/client/cjs/@prismicio/client.js:1059:27
22:13:41.012        at DefaultApiCache.get (/vercel/path0/node_modules/@prismicio/client/cjs/@prismicio/client.js:956:19)
22:13:41.012    info  - Generating static pages (3/7)
22:13:41.025    info  - Generating static pages (5/7)
22:13:41.057    info  - Generating static pages (7/7)
22:13:41.058    > Build error occurred
22:13:41.060    Error: Export encountered errors on following paths:
22:13:41.060        /posts
22:13:41.060        at /vercel/path0/node_modules/next/dist/export/index.js:31:1106
22:13:41.061        at runMicrotasks (<anonymous>)
22:13:41.061        at processTicksAndRejections (internal/process/task_queues.js:95:5)
22:13:41.062        at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
22:13:41.062        at async /vercel/path0/node_modules/next/dist/build/index.js:43:49
22:13:41.062        at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
22:13:41.062        at async /vercel/path0/node_modules/next/dist/build/index.js:25:1529
22:13:41.062        at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/telemetry/trace/trace.js:6:584)
22:13:41.094    error Command failed with exit code 1.
22:13:41.094    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
22:13:41.117    Error: Command "yarn run build" exited with 1

0 Answers0