diff --git a/.changeset/selfish-parents-leave.md b/.changeset/selfish-parents-leave.md new file mode 100644 index 0000000000..206fa08e12 --- /dev/null +++ b/.changeset/selfish-parents-leave.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Improves the error message when a middleware doesn't return a `Response` diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 5a1a5fbcc7..047bb53372 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -733,8 +733,9 @@ export const ResponseSentError = { */ export const MiddlewareNoDataOrNextCalled = { name: 'MiddlewareNoDataOrNextCalled', - title: "The middleware didn't return a response or call `next`.", - message: 'The middleware needs to either return a `Response` object or call the `next` function.', + title: "The middleware didn't return a `Response`.", + message: + 'Make sure your middleware returns a `Response` object, either directly or by returning the `Response` from calling the `next` function.', } satisfies ErrorData; /**