chatbot-ui icon indicating copy to clipboard operation
chatbot-ui copied to clipboard

Maybe we should bypass the image user uploaded from Vercel

Open zaoying opened this issue 11 months ago • 4 comments

I recently uploaded a picture for avatar, then I received a waring from Vercel says Chatbot App have consumed more than 300% resource. image

Maybe we should just upload the image or file to some cdn provider. Then link to it directly instead of requesting it by Vercel.

zaoying avatar Mar 12 '24 02:03 zaoying

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.

tysonvolte avatar Mar 12 '24 09:03 tysonvolte

probably the last modification date should be appended

fkesheh avatar Mar 13 '24 03:03 fkesheh

@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()}`

tysonvolte avatar Mar 13 '24 03:03 tysonvolte

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"]
    }
  })
)

vood avatar Mar 17 '24 20:03 vood