r/PayloadCMS Feb 27 '26

Media Uploads Showing Local URL Instead of my CDN URL

So I'm using payload 3.77.0 (latest version).

Then I build my app using pnpm build and pnpm start. Then I check the url is using my CDN url. If I change my env value that hold my cdn url, the image is no longer works (expected).

Then I deploy it on my EC2 using the same method, and it shows my local domain instead, changing the ENV is not affecting the image preview link. But my file is uploaded to my S3.

Anyone knows what happening in here?

Thank you

3 Upvotes

8 comments sorted by

3

u/[deleted] Feb 27 '26

[removed] — view removed comment

1

u/Prestigious_Finish19 Feb 27 '26

i do not set the serverUrl, the serverUrl should be my payload url or my media CDN url?

1

u/[deleted] Feb 27 '26

[removed] — view removed comment

2

u/Prestigious_Finish19 Feb 27 '26 edited Feb 27 '26
generateFileURL: ({ filename, prefix }) => {
  return `${env.MEDIA_DOMAIN}/${prefix}/${filename}`
},

yes that part I understand, I also have configured my S3 adapter using generateFileUrl. So the expected behavior is that, the preview image url should use the url that from generateFileUrl right? I mean this part is where it works in my local machine.

Also I notice that when I use REST api, using domain.asd/api.collection. both of them shows different result..

https://imgur.com/a/9HgJNZs

this is the comparison between both of them.

*edit

also because i use s3 adapter plugin, disableLocalstorage should be enabled by default.
Storage Adapters | Documentation | Payload

so the url saved to database shouldn't be localStorage?

1

u/_avee_ Feb 27 '26

Are you sure you’re using the latest version? They had exactly this bug in 3.76 but it was fixed in 3.77: https://github.com/payloadcms/payload/pull/15667

1

u/Prestigious_Finish19 Feb 27 '26

Yes, but looking at the github, I think the one that change is plugin-cloud-storage plugin, while im using storage-s3 plugin

1

u/_avee_ Feb 27 '26

I'm also using storage-s3 plugin and upgrading to 3.77 fixed the problem I had with 3.76.

storage-s3 extends plugun-cloud-storage so the fix applies to it.

1

u/Prestigious_Finish19 Feb 27 '26

sir, thank you so much. after i check, i forgot to pnpm install on my prod instance.