Getting empty response for images in Netlify

when I run website locally I get images but after deployment getting empty response for image.
http://localhost:4200/assets/images/galleryPics/g%20(1).webp

@SohailAnsari I’m guessing you have this rewrite on your site:

https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps

/*  /index.html  200

You’re trying to load an image here:

https://kgncaterers.in/assets/images/galleryPics/g%20(1).webp

But since it doesn’t exist, the rewrite is returning the source of your index.html file:

So it isn’t that there is an ‘empty response’ or that the image is blank, it’s that it’s HTML.

Due to the rewrite you would see this for any URL that doesn’t exist, for example:
https://kgncaterers.in/this/path/does/not/exist/and-this-file-does-not-exist-either.jpg

It’s also why the site loads when you access that link.

So you need to make sure the images are where you think they are in the deployment.

Ways you can check this are:

  • Run your build locally, (not any development server you may have), and see what it outputs
  • Use the Netlify Deploy File Browser

I am not using rewrite and I checked photo is available in build also.
but still not getting image after deployment

this is website link where images are not loading: KGN Caterers | Our Gallery
and on this page images are loading KGN Caterers | About Us

I was using file names like image (1).webp, image (2).webp.
but after changing it to random names, its working now( I don’t know how).
thanks @nathanmartin for supporting me.

Then how do you explain this?..

https://kgncaterers.in/i/guarantee/this/page/does/not/exist/on/your/site

https://kgncaterers.in/i/guarantee/this/page/does/not/exist/on/your/site

Are you saying you have a page called:

/i/guarantee/this/page/does/not/exist/on/your/site.html

Visiting that URL, you’ll end up back at https://kgncaterers.in

  • The default behavior would be a 404 error
  • The status returned is not a redirect (e.g. 301/302)
  • The response is a 200 status and the HTML of your index.html file

The explanation for that is the Single Page Application rewrite that I linked to in the documentation.

If you don’t have a _redirects file, check if you have a netlify.toml file.

It sounds to me like you solved it exactly as I said you needed to.

You determined why the requests for the images weren’t matching where they actually were