Skip to content

[v4] Default public directory can't be overwritten #11907

@h00x

Description

@h00x

Bug report

I'm unable to change the directory of the public path.

Describe the bug

According to this documentation you're able to overwrite the default path of the public directory. Changing it in config/middlewares.js to:

{
  name: 'strapi::public',
  config: {
    path: env('PUBLIC_DIRECTORY', '/data/public'),
  },
},

does nothing to the public path.

Steps to reproduce the behavior

  1. Change the public path in config/middlewares.js by changing strapi::public to an object with a config and a path property
  2. Restart the server
  3. Upload something
  4. Can't find the uploaded file in the test directory but you are able to find it in public/uploads

Expected behavior

I expect the public directory and the content that I upload to be set to the path value I specify in config/middlewares.js.

Code snippets

Example of the change to strapi::public in config/middlewares.js.

{
  name: 'strapi::public',
  config: {
    path: './test',
  },
},

System

  • Node.js version: 14.18.2
  • NPM version: 6.14.15
  • Strapi version: 4.0
  • Database: SQLite
  • Operating system: Debian GNU/Linux 10 (buster)

Additional context

Trying to get Strapi v4 working on Render.com. Changing the public path is the only thing holding me back using Strapi v4 on an ephemeral environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bugIssue reporting a bugseverity: lowIf the issue only affects a very niche base of users and an easily implemented workaround can solvesource: core:strapiSource is core/strapi packagestatus: confirmedConfirmed by a Strapi Team member or multiple community members

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions