opened 11:28AM - 16 May 24 UTC
## Bug report
Following from https://discord.com/channels/811989166782021633/12…40319511857463429
Seems there is error in doc's or in the way the global middleware imported.
I try to follow steps from docs https://docs.strapi.io/dev-docs/backend-customization/middlewares to add global middleware and ran in to issue.
### Required System information
- Node.js version: v18.18.2
- NPM version: 8.13.1
- Strapi version: 4.17.1
- Database: Postgres
- Operating system: windows 10 pro
- Is your project Javascript or Typescript: Typescript
### Describe the bug
A clear and concise description of what the bug is.
### Steps to reproduce the behavior
1. Add middleware to an empty project `src/middlewares/test.ts`
```ts
export default (config, { strapi }) => {
return async (ctx, next) => {
console.log('test');
await next();
};
};
```
2. Add middleware to `config/middlewares.ts`
```ts
export default [
'strapi::errors',
'strapi::security',
'strapi::cors',
'strapi::poweredBy',
'strapi::logger',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
'global::test ',
];
```
3. Error:
```sh
Error: Middleware global::test not found.
```
### Expected behavior
It should work
### Additional context
```sh
$ strapi middlewares:list
┌─────────────────────────────────────┐
│ Name │
├─────────────────────────────────────┤
│ admin::rateLimit │
├─────────────────────────────────────┤
│ admin::data-transfer │
├─────────────────────────────────────┤
│ global::test │
├─────────────────────────────────────┤
│ strapi::compression │
├─────────────────────────────────────┤
│ strapi::cors │
├─────────────────────────────────────┤
│ strapi::errors │
├─────────────────────────────────────┤
│ strapi::favicon │
├─────────────────────────────────────┤
│ strapi::ip │
├─────────────────────────────────────┤
│ strapi::logger │
├─────────────────────────────────────┤
│ strapi::poweredBy │
├─────────────────────────────────────┤
│ strapi::body │
├─────────────────────────────────────┤
│ strapi::query │
├─────────────────────────────────────┤
│ strapi::responseTime │
├─────────────────────────────────────┤
│ strapi::responses │
├─────────────────────────────────────┤
│ strapi::security │
├─────────────────────────────────────┤
│ strapi::session │
├─────────────────────────────────────┤
│ strapi::public │
├─────────────────────────────────────┤
│ plugin::users-permissions.rateLimit │
└─────────────────────────────────────┘
```