Model config path uses uid instead of dot notation
In Strapi 5, to retrieve config values you will need to use config.get('plugin::upload.myconfigval')
or config.get('api::myapi.myconfigval')
This page is part of the breaking changes database and provides information about the breaking change and additional instructions to migrate from Strapi v4 to Strapi 5.
🔌 Is this breaking change affecting plugins? | Yes |
---|
🤖 Is this breaking change automatically handled by a codemod? | Partly |
---|
Breaking change description
In Strapi v4
Models are added to the configuration using .
notation as follows:
strapi.config.get('plugin.upload.somesetting');
if ( strapi.config.has('plugin.upload.somesetting') ) {
strapi.config.set('plugin.upload.somesetting', false);
}
In Strapi 5
Models are added to the configuration using ::
replacing .
notation as follows:
strapi.config.get('plugin::upload.somesetting');
if ( strapi.config.has('plugin::upload.somesetting') ) {
strapi.config.set('plugin::upload.somesetting', false);
}
Migration
This section regroups useful notes and procedures about the introduced breaking change.
Notes
If an API has a configuration, it should also be accessed using
strapi.config.get(’api::myapi.myconfigval’)
.The 'plugin' namespace has temporary support with a deprecation warning. This means that referencing
plugin.upload.somesetting
will emit a warning in the server log and checkplugin::upload.somesetting
instead.A codemod has been created to assist in refactoring the strings in user code, replacing
plugin.
orapi.
withplugin::
andapi::
.
Manual procedure
A codemod will automatically handle the change in most cases.
In cases were the codemod does not automatically handle the change, users will need to manually replace all their strings to target the new config paths.