#Fixing Image Uploads in Payload on Vercel & Supabase

34 messages · Page 1 of 1 (latest)

lilac ibexBOT
#

Hi,

I’ve installed the Payload website template, deployed it on Vercel, and connected it to the Supabase free tier. Everything is working fine, except for images on Vercel. I can’t upload them to the database, and they also don’t display properly. I’m getting 400 and 502 errors. Everything works fine locally.

What could be the issue, and how can I fix it?

lyric spireBOT
#

Original message from @inland gust - Moved from #general message

livid spoke
#

Hey @inland gust

So you've built your app and have deployed it to Vercel, correct?

inland gust
#

Yes

livid spoke
#

Now when trying to view images you get errors

#

Which storage adapter are you using?

#

With Serverless, this is not unique to just Vercel but any serverless environment, their filesystem is ephemeral. This means that as soon as execution is stopped on that function that anything residing in the local filesystem will get wiped along with that function. You need a persistence layer to persist these uploads somewhere outside of the filesystem.

inland gust
#

Can I use supabase bucket for this?

livid spoke
#

I think Supabase storage has an S3-compatible API, so you would use the S3 adapter - so yes, I think it would work.

inland gust
#

@livid spoke ok, i added s3 supabase bucket and it works for new images, for the old ones from the seed function should I reupload them?

livid spoke
#

Yeah, reuploading would be your best move here

#

But otherwise it's working now?

inland gust
#

deploying rn, I thought s3 was optional

livid spoke
#

It is on something like a VPS, but for serverless there are other nuances as I mention above

inland gust
#

Do I enable fluid compute on vercel for payload?

livid spoke
#

No need

#

I'm not 100% certain on how fluid works with Payload as of yet to be honest

#

But I don't see any reason why it wouldn't work

inland gust
#

Ok, one more question, how to create localized route name eg. /en/about, /pl/o-nas for pages?

livid spoke
inland gust
#

I upadated image on hero section on home page and it was saved ok but i dont see changes yet, website template has path revalidation?

livid spoke
#

Yeah, it may be cache. Just make sure you have the revalidation hook set from the example and it should update after saving.

inland gust
#

ok it works, i had to redeploy

livid spoke
#

Nice, glad we figured it out here!

lyric spireBOT
inland gust
#

but its weird that revalidatepath is not working correctly, i have fresh install of website template, whats the best db for payload?

livid spoke
#

revalidatePath should definitely work

#

There's no "best" db for Payload really, but if you're deploying to Vercel and you want to use PG, then you should use the "vercel-postgres" adapter

inland gust