strapi-mdn-provider
v1.0.0
Published
Strapi v5 upload provider for Check's MDN media service (mdn.check-dc.com). Stores the absolute MDN URL.
Downloads
168
Maintainers
Readme
@wearecheck/strapi-mdn-provider
Strapi v5 upload provider for Check's MDN media service (mdn.check-dc.com).
Uploads files to MDN and stores the absolute MDN URL in Strapi, so media is
portable across environments and survives a DB dump/restore without rewriting rows.
Install
npm install @wearecheck/strapi-mdn-provider
# or: pnpm add @wearecheck/strapi-mdn-providerConfigure
config/plugins.ts:
export default ({ env }) => ({
upload: {
config: {
provider: '@wearecheck/strapi-mdn-provider',
providerOptions: {
apiKey: env('MDN_API_KEY'),
baseUrl: env('MDN_BASE_URL'), // e.g. https://mdn.check-dc.com
folder: env('MDN_FOLDER'), // directory assets are stored under
prefix: env('MDN_PREFIX'), // optional, defaults to "strapi-mdn"
},
},
},
});Allow the host through the admin CSP
The Strapi admin blocks external image hosts by default, so add the MDN host to
the security middleware in config/middlewares.ts:
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'img-src': ["'self'", 'data:', 'blob:', 'market-assets.strapi.io', process.env.MDN_BASE_URL],
'media-src': ["'self'", 'data:', 'blob:', 'market-assets.strapi.io', process.env.MDN_BASE_URL],
},
},
},
}Options
| Option | Env | Required | Description |
| --------- | -------------- | -------- | -------------------------------------------------------- |
| apiKey | MDN_API_KEY | yes | Sent as the X-Signature header. |
| baseUrl | MDN_BASE_URL | yes | MDN host, e.g. https://mdn.check-dc.com. |
| folder | MDN_FOLDER | yes | Directory assets are stored under. |
| prefix | MDN_PREFIX | no | Filename prefix (default strapi-mdn). |
Notes
- Serialized requests. MDN's backend (SQLite) can't take concurrent writes, and Strapi uploads/deletes the original plus every responsive format in parallel, so the provider funnels all requests through a one-at-a-time queue.
- AVIF. MDN does not accept AVIF uploads yet; transcode to WebP/etc. beforehand.
- Requires Node 18+ (uses the global
fetch/FormData).
