#images work in dev but not prod

10 messages · Page 1 of 1 (latest)

unreal bear
#

every image i have on my site is working in dev but none are working (consistently) in prod.

all my images are stored directly in public/ folder. I have tried referencing them with relative imports and then using the variable in the src= of <Image />, using <Image src={var.src} /> and using things such as <Image src="/image.jpg" /> and none of them are working in prod. sometimes some of them render and then break after wards.

<Image src={`/imageName.jpg`} height='400' width="500" className='mt-3 mb-5' />```
and ```     
import imageName from '../public/imageName.png';

           <Image 
                id='mainLogo'
                alt="Logo" 
                className='mx-auto mt-5 pb-5' 
                // layout="responsive" 
                // placeholder="blur"
                priority
                src={imageName.src} 
                height="250vh"
                width="600vh" 
                />```
and tried using 
```json
 publicRuntimeConfig: {
        // Will be available on both server and client
         staticFolder: process.env.DEV ? "" : '/',
     },```
in my next.config.js as well as adding my domains to the next.config.js
unreal bear
#

ive tried basically everything i can think of other than falling back to a standard img tag, but ironically the <Image /> optimizations were the main reason I choose to migrate to next.js from a regular react/express app.

#

ive modified my folder structure to go from public/assets/images/brands/imageName.jpg to just public/imageName.jpg, tried adding in "trailingSlash: true" to my config file, and every permutation imaginable of importing/referencing the image paths in the image tag src property.

#

I will really be grateful for anyone who can help me get this working

unreal bear
#

bump

uneven onyx
#

what hosting service are you using? I remember having this issue a while ago with AWS. for AWS, there's some extra configuration you need to do

unreal bear
#

Heroku

#

Even some images that do load on certain attempts break during the same browsing session

#

Ive read the heroku docs on next js and followed the instructions. Didnt seem like there was much to do

unreal bear
#

testing now, but it seems that i needed to install sharp dependency for production according to a post i found on SO. I guess Vercel does this by default so its not prominently mentioned in the config steps. Changed a couple components and it seemed to work, trying a deploy with everything switched over now. Thanks for pointing me in the right direction on this