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:
parent
562054e8e1
commit
e39ee5662d
1 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue