Undefined Public Folder while Upload

System Information
  • Strapi Version: 4.3.0
  • Operating System:
  • Database: SQLite
  • Node Version:
  • NPM Version:
  • Yarn Version:

This is my log after trying to upload an simple image. But “undefined” is wrong and has to be “public”.

[2022-08-02 21:06:09.483] debug: IPX Error (File not found (/opt/app/undefined/uploads/thumbnail_XXX_2020_10_07_0068_0124b006aa.jpg))
IPXError: File not found (/opt/app/undefined/uploads/thumbnail_XXX_2020_10_07_0068_0124b006aa.jpg)
    at createError (/opt/app/node_modules/ipx/dist/chunks/middleware.cjs:76:15)
    at Object.filesystem (/opt/app/node_modules/ipx/dist/chunks/middleware.cjs:94:15)
    at async ipxMiddleware (/opt/app/node_modules/strapi-plugin-local-image-sharp/strapi-server.js:44:19)
    at async /opt/app/node_modules/@strapi/strapi/lib/services/metrics/middleware.js:29:5 {
  statusMessage: 'IPX: File not found',
  statusCode: 404

I tried this in my middleware.js without success:

    name: 'strapi::public',
    config: {
      path: '/opt/app/public/',

The Upload itself is okay and works well, but after that the error comes up.

This is the Url and maybe the url in the Media Library is wrong:

Facing the same issue, looks like it is not recognizing the public folder.

This issue exists also in the new version 4.3.6 … any ideas to solve this behavior?

One step closer to a solution:

I found the line of code where the issue comes from in the file node_modules\strapi-plugin-local-image-sharp\strapi-server.js

    const ipx = createIPX({
      dir: `${strapi.dirs?.dist?.public ?? strapi.dirs?.public}/uploads`,

The variable strapi.dirs.public are undefined and I just added an ?? “public” and it works.

    const ipx = createIPX({
      dir: `${strapi.dirs?.dist?.public ?? strapi.dirs?.public ?? "public"}/uploads`,

Where can I configure the strapi.dirs.public?

I uninstalled the “strapi-plugin-local-image-sharp” and it works fine … this is an issue with plugin.