0

I have a blog-like project in Astro that works perfectly locally. When I deploy it on Vercel, the images under src won't load. My project tree looks as follows:

.  
└── src/  
    ├── content/  
    │   ├── projects/  
    │   │   ├── images/  
    │   │   │   └── image-example.png  
    │   │   └── project-example.md  
    │   └── config.ts  
    └── pages/  
        ├── project/  
        │   └── [slug].astro  
        ├── tags/  
        │   └── [tag].astro  
        └── index.astro  

I tried moving all the imgaes to public, which made them load but incredibly slowly, and when I try to click into any tag, blog post, etc., I get this: enter image description here or this: enter image description here

For whatever reason, the favicon also refuses to load when deployed to Vercel even though it shows up as the project icon and locally. Not sure if this is related to a larger problem. Would appreciate any help.

3
  • If you want astro to compress the images, they definitely should go under src/... What happens if you do npm run build locally? can you reproduce the problem there? See also docs.astro.build/en/guides/images
    – mb21
    Commented Jul 7 at 7:27
  • @mb21 , yes, it built fine locally. I had to change my path to get it to do so, but it ended up building every time I tried running npm run build locally. I looked through the link you postted (and basically everything I could find on images in Astro) already. But yes, my biggest confusion is around why it works fine locally and then proceeds not to work in Vercel.
    – Josephine
    Commented Jul 8 at 16:39
  • I assume you made sure all files are checked into git? Are there any errors on vercel build logs? If it still doesn't work maybe try Netlify 🤷🏽‍♂️
    – mb21
    Commented Jul 8 at 18:37

0

Browse other questions tagged or ask your own question.