Skip to content

Commit ee2734c

Browse files
authored
docs: add troubleshooting for middlewares (medusajs#13764)
1 parent e36c054 commit ee2734c

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

www/apps/book/app/learn/customization/custom-features/api-route/page.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ This returns the created brand in the response:
218218
}
219219
```
220220

221+
### Troubleshooting
222+
223+
#### Returned Empty Array
224+
225+
If you sent a request to the API route and received an empty array in the response, make sure you've correctly created the middleware at `src/api/middlewares.ts` (with correct spelling). This is a common mistake that can lead to the middleware not being applied, resulting in unexpected behavior.
226+
221227
---
222228

223229
## Summary

www/apps/book/app/learn/fundamentals/api-routes/middlewares/page.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ npm run dev
167167
Received a request!
168168
```
169169

170+
### Troubleshooting
171+
172+
If the middleware didn't run, make sure you've correctly created the middleware at `src/api/middlewares.ts` (with correct spelling). This is a common mistake that can lead to the middleware not being applied, resulting in unexpected behavior.
173+
170174
---
171175

172176
## When to Use Middlewares

www/apps/book/generated/edit-dates.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const generatedEditDates = {
4646
"app/learn/fundamentals/admin/tips/page.mdx": "2025-10-03T08:35:15.022Z",
4747
"app/learn/fundamentals/api-routes/cors/page.mdx": "2025-03-11T08:54:26.281Z",
4848
"app/learn/fundamentals/admin/ui-routes/page.mdx": "2025-07-25T06:58:26.149Z",
49-
"app/learn/fundamentals/api-routes/middlewares/page.mdx": "2025-07-18T15:20:25.735Z",
49+
"app/learn/fundamentals/api-routes/middlewares/page.mdx": "2025-10-16T11:23:37.787Z",
5050
"app/learn/fundamentals/modules/isolation/page.mdx": "2025-05-21T15:10:15.499Z",
5151
"app/learn/fundamentals/data-models/index/page.mdx": "2025-03-18T07:59:07.798Z",
5252
"app/learn/fundamentals/custom-cli-scripts/page.mdx": "2025-07-25T15:32:47.587Z",
@@ -72,7 +72,7 @@ export const generatedEditDates = {
7272
"app/learn/debugging-and-testing/instrumentation/page.mdx": "2025-06-16T10:40:52.922Z",
7373
"app/learn/fundamentals/api-routes/additional-data/page.mdx": "2025-04-17T08:50:17.036Z",
7474
"app/learn/fundamentals/workflows/variable-manipulation/page.mdx": "2025-04-24T13:14:43.967Z",
75-
"app/learn/customization/custom-features/api-route/page.mdx": "2024-12-09T10:39:30.046Z",
75+
"app/learn/customization/custom-features/api-route/page.mdx": "2025-10-16T11:23:11.195Z",
7676
"app/learn/customization/custom-features/module/page.mdx": "2025-05-06T16:10:50.090Z",
7777
"app/learn/customization/custom-features/workflow/page.mdx": "2024-12-09T14:36:29.482Z",
7878
"app/learn/customization/extend-features/extend-create-product/page.mdx": "2025-01-06T11:18:58.250Z",

www/apps/book/public/llms-full.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,12 @@ This returns the created brand in the response:
13841384
}
13851385
```
13861386

1387+
### Troubleshooting
1388+
1389+
#### Returned Empty Array
1390+
1391+
If you sent a request to the API route and received an empty array in the response, make sure you've correctly created the middleware at `src/api/middlewares.ts` (with correct spelling). This is a common mistake that can lead to the middleware not being applied, resulting in unexpected behavior.
1392+
13871393
***
13881394

13891395
## Summary
@@ -8180,6 +8186,10 @@ npm run dev
81808186
Received a request!
81818187
```
81828188

8189+
### Troubleshooting
8190+
8191+
If the middleware didn't run, make sure you've correctly created the middleware at `src/api/middlewares.ts` (with correct spelling). This is a common mistake that can lead to the middleware not being applied, resulting in unexpected behavior.
8192+
81838193
***
81848194

81858195
## When to Use Middlewares

0 commit comments

Comments
 (0)