Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

393
Views
Server Error Error: Unable to resolve image URL from source (undefined)

I am trying to make pizza website and when I click to the pizza information it show this error: Server Error Error: Unable to resolve image URL from source (undefined) This is my [slug.js]:

import css from '../../styles/Pizza.module.css'
import Layout from '../../components/Layout'
import { client, urlFor } from '../../lib/client';
import Image from 'next/image'



export default function Pizza( pizza ) { 
    const src = urlFor(pizza.image).url()  
    return (
        <Layout>
            <div className={css.container}>
                <div className={css.imageWrapper}>
                    <Image 
                    loader={()=> src}
                    alt=''
                    src={src} layout='fill' unoptimized objectFit='cover'/>
                </div>
            </div>
        </Layout>
    );
}

export async function getStaticPaths() {
    const paths = await client.fetch(
        `*[_type=="pizza" && defined(slug.current)][].slug.current`
    );

    return {
        paths: paths.map((slug)=> ({params: {slug}})),
        fallback: 'blocking',
    }
}

export async function getStaticProps(context) {
    const {slug = ""} = context.params;
    const pizza = await client.fetch(
        `*[_type=="pizza" && slug.current == ${slug}][0]`
    );
    return {
        props: {
            pizza,
        },
    };
}

And This Is My client.js:

import sanityClient from '@sanity/client';
import ImageUrlBuilder from '@sanity/image-url';
export const client = sanityClient({
    projectId: 'fzrtqgg5',
    dataset: 'production',
    apiVersion: "2022-08-26",
    useCdn: true,
    token: 
    "skbb3liMqr3eQniDCvA0XzPQjjCqx4q0DgEbi2FeqhGcT6SjVfT9krLhV4KAELgyJxnaifSxITf1j9gJUZ4W1fSCONMVehDiL5Gd6wNVyx4uqnKghGh6zsEtoNUWxMqsztb3CidyRBbwR99p8XlIPYg3SgtDsTAf412OCDngizvLkFbqFsNE"
})

const builder = ImageUrlBuilder(client);

export const urlFor = (source) => builder.image(source)

I have search Google for like 8 hours but it all don't work.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!