summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorGravatar Emanuele Stoppa <my.burning@gmail.com> 2024-05-08 16:03:03 +0100
committerGravatar GitHub <noreply@github.com> 2024-05-08 16:03:03 +0100
commite39ee5662d870a91a75b6b3ac441b9e3ef9e1063 (patch)
tree080d7d44b7c26b6ee5a129240f7a2402dadb30dd /packages
parent562054e8e165e39becb50d0fcd2008bc824ef724 (diff)
downloadastro-e39ee5662d870a91a75b6b3ac441b9e3ef9e1063.tar.gz
astro-e39ee5662d870a91a75b6b3ac441b9e3ef9e1063.tar.zst
astro-e39ee5662d870a91a75b6b3ac441b9e3ef9e1063.zip
fix: logic for printing warning (#10976)
Diffstat (limited to 'packages')
-rw-r--r--packages/astro/src/core/middleware/callMiddleware.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/astro/src/core/middleware/callMiddleware.ts b/packages/astro/src/core/middleware/callMiddleware.ts
index b92e0f3cb..d52ba0126 100644
--- a/packages/astro/src/core/middleware/callMiddleware.ts
+++ b/packages/astro/src/core/middleware/callMiddleware.ts
@@ -56,13 +56,15 @@ export async function callMiddleware(
let responseFunctionPromise: Promise<Response> | Response | undefined = undefined;
const next: MiddlewareNext = async (payload) => {
nextCalled = true;
- if (enableRerouting) {
- responseFunctionPromise = responseFunction(apiContext, payload);
- } else {
+ if (!enableRerouting && payload) {
logger.warn(
'router',
'The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config.'
);
+ }
+ if (enableRerouting) {
+ responseFunctionPromise = responseFunction(apiContext, payload);
+ } else {
responseFunctionPromise = responseFunction(apiContext);
}
// We need to pass the APIContext pass to `callMiddleware` because it can be mutated across middleware functions