Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
18 lines
463 B
Text
18 lines
463 B
Text
import type { Middleware } from "./common";
|
|
|
|
const drainBody: Middleware = async (request, env, _ctx, middlewareCtx) => {
|
|
try {
|
|
return await middlewareCtx.next(request, env);
|
|
} finally {
|
|
try {
|
|
if (request.body !== null && !request.bodyUsed) {
|
|
const reader = request.body.getReader();
|
|
while (!(await reader.read()).done) {}
|
|
}
|
|
} catch (e) {
|
|
console.error("Failed to drain the unused request body.", e);
|
|
}
|
|
}
|
|
};
|
|
|
|
export default drainBody;
|