Image attachments not being shown in production #683
-
I'm self-hosting Teable on Railway and it's an amazing experience so far. We have an attachment column where users can upload a picture. I'm using the records API to get the record and I see a presignedUrl like so
When I use this URL to show this image, it works locally, but when deployed to Vercel, the image doesn't load for some reason. When I paste the URL directly, I see the image so not sure if CORS issue. The url has private, should that be changed to public to access? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
The pre-signed URL has an expiration time(hours), and it becomes inaccessible after it expires. It is recommended that you request the latest image URL each time, and you can also use the "next Image" tag to cache the image. |
Beta Was this translation helpful? Give feedback.
-
So I am getting the latest presignedUrl every time and not using an expired image URL. To reproduce, upload an image on Teable and use the presignedUrl in an img tag in a HTML editor. The only solution that works is to create a Next.js API route:
This works, but not with the Next/Image component, only the normal img tag. It also takes forever to load since it's routing the image thru an API route and then showing it. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/teableio/template-site/blob/main/src/app/page.tsx For an example on the official template site, the Next Image tab uses presignedUrl directly |
Beta Was this translation helpful? Give feedback.
-
I may have figured out the reason, next image security policy is blocking access to external domains, you need to add a configuration:
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '*.your-prefix.railway.app',
},
],
},
};
export default nextConfig; |
Beta Was this translation helpful? Give feedback.
I may have figured out the reason, next image security policy is blocking access to external domains, you need to add a configuration: