Skip to content

Commit

Permalink
fix: logic for printing warning (#10976)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored May 8, 2024
1 parent 562054e commit e39ee56
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/astro/src/core/middleware/callMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e39ee56

Please sign in to comment.