0

Getting 404 error when go to project page router.js:250 GET http://localhost:3000/_next/data/development/en/projects/missing-middle.json?slug=missing-middle 404 (Not Found)

When reload project page it looks fine.

Structures of sanity and pages

(https://i.stack.imgur.com/kGm6z.png) (https://i.stack.imgur.com/0Grdw.png)

const data = await sanityClient.fetch(pageQuery, queryParams)

gives empty data when fetching project page.

queryParams = slug pageQuery

export const buildBlockProjections = () => {
    const projections = [
        '...',
        `markDefs[]{..., _type == "link" => {..., "target":{...(@.target->{_type, slug, "parent":{...(parent->{slug, "parent":{...(parent->{slug})}})}})}}}`
    ]
    for (const block in blocks) {
        const blockProjections = blocks[block]?.projections
        if (blockProjections) {
            const projectionsList = (typeof blockProjections === 'function') ? blockProjections() : blockProjections
            projections.push(`_type == "${block}" => {${projectionsList.join(',')}}`)
        }
    }
    return projections
}

const pageProjections = [
    `...`,
    `"parent":{...(parent->{slug, title, "parent":{...(parent->{slug, title})}})}`,
    `"media":{...media, "asset":media.asset->{_id,path,url,"metadata":{"dimensions":metadata.dimensions, "lqip":metadata.lqip}}}`,
    `"blocks":blocks[]{${buildBlockProjections().join(',')}}`
]

export const pageQuery = groq`*[_type == "page" && slug.current == $slug]{${pageProjections.join(',')}}`

0 Answers0