chatbot-ui
chatbot-ui copied to clipboard
Maybe we should bypass the image user uploaded from Vercel
I recently uploaded a picture for avatar, then I received a waring from Vercel says Chatbot App have consumed more than 300% resource.
Maybe we should just upload the image or file to some cdn provider. Then link to it directly instead of requesting it by Vercel.
Just had the same issue ($40 Image Optimisation overage though!) and fixed it. It's due to date.now() being appended to the image URL after the ?. Since it's a new URL every time, Vercel sees it as a unique image and increments your counter.
probably the last modification date should be appended
@fkesheh the last modification date is the filename itself and is set when uploaded From profile-images.ts:
const currentPath = profile.image_path
let filePath = `${profile.user_id}/${Date.now()}`
Here is how to disable image optimization in next.config.js
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true"
})
const withPWA = require("next-pwa")({
dest: "public"
})
module.exports = withBundleAnalyzer(
withPWA({
reactStrictMode: true,
images: {
unoptimized: true,
remotePatterns: [
{
protocol: "http",
hostname: "localhost"
},
{
protocol: "http",
hostname: "127.0.0.1"
},
{
protocol: "https",
hostname: "**"
}
]
},
experimental: {
serverComponentsExternalPackages: ["sharp", "onnxruntime-node"]
}
})
)