-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Closed as not planned
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundIf it breaks the basic use of the product but can be worked aroundsource: typescriptSource is related to TypeScript (typings, tooling, ...)Source is related to TypeScript (typings, tooling, ...)stalestale-q1-q2-2024status: pending reproductionWaiting for free time to reproduce the issue, or more informationWaiting for free time to reproduce the issue, or more information
Description
Bug report
Following from https://discord.com/channels/811989166782021633/1240319511857463429
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
- Add middleware to an empty project
src/middlewares/test.ts
export default (config, { strapi }) => {
return async (ctx, next) => {
console.log('test');
await next();
};
};- Add middleware to
config/middlewares.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 ',
];- Error:
Error: Middleware global::test not found. Expected behavior
It should work
Additional context
$ 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 │
└─────────────────────────────────────┘Metadata
Metadata
Assignees
Labels
issue: bugIssue reporting a bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundIf it breaks the basic use of the product but can be worked aroundsource: typescriptSource is related to TypeScript (typings, tooling, ...)Source is related to TypeScript (typings, tooling, ...)stalestale-q1-q2-2024status: pending reproductionWaiting for free time to reproduce the issue, or more informationWaiting for free time to reproduce the issue, or more information
Type
Projects
Status
Fixed/Shipped