0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

fix: logic for printing warning (#10976)

This commit is contained in:
Emanuele Stoppa 2024-05-08 16:03:03 +01:00 committed by GitHub
parent 562054e8e1
commit e39ee5662d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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