跳到主要内容

How to use public assets with Strapi

🏗 Work in progress

The content of this page might not be fully up-to-date with Strapi 5 yet.

Public assets are static files (e.g. images, video, CSS files, etc.) that you want to make accessible to the outside world.

Because an API may need to serve static assets, every new Strapi project includes by default a folder named /public. Any file located in this directory is accessible if the request's path doesn't match any other defined route and if it matches a public file name (e.g. an image named company-logo.png in ./public/ is accessible through /company-logo.png URL).

💡 Tip

index.html files are served if the request corresponds to a folder name (/pictures url will try to serve public/pictures/index.html file).

Caution

The dotfiles are not exposed. It means that every file name that starts with ., such as .htaccess or .gitignore, are not served.