Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

398
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda