Skip to content

Commit

Permalink
fix middleware wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
edivados committed Jul 22, 2024
1 parent 6aa7d1f commit e93153b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/start/src/middleware/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ function wrapRequestMiddleware(onRequest: RequestMiddleware) {
return async (h3Event: HTTPEvent) => {
const fetchEvent = getFetchEvent(h3Event);
const response = await onRequest(fetchEvent);
if (!response) {
return;
} else {
sendWebResponse(h3Event, response);
if (response) {
await sendWebResponse(h3Event, response);
}
};
}
Expand All @@ -39,10 +37,8 @@ function wrapResponseMiddleware(onBeforeResponse: ResponseMiddleware) {
return async (h3Event: HTTPEvent, response: ResponseMiddlewareResponseParam) => {
const fetchEvent = getFetchEvent(h3Event);
const mwResponse = await onBeforeResponse(fetchEvent, response);
if (!mwResponse) {
return;
} else {
sendWebResponse(h3Event, mwResponse);
if (mwResponse) {
response.body = mwResponse;
}
};
}
Expand Down

0 comments on commit e93153b

Please sign in to comment.