Rocky_Mountain_Vending/.pnpm-store/v10/files/8c/d1b00d5ed31b0910f5b96ea1b1488129423a70e2269ba8f5038399b666cef3959ea5992fb10211948845f273204f45221500fc77a86b81df11fe22b7cd2ad0
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
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>
2026-02-12 16:22:15 -07:00

29 lines
1 KiB
Text

import type { Middleware } from "./common";
// A middleware has to be a function of type Middleware
const scheduled: Middleware = async (request, env, _ctx, middlewareCtx) => {
const url = new URL(request.url);
if (url.pathname === "/__scheduled") {
const cron = url.searchParams.get("cron") ?? "";
await middlewareCtx.dispatch("scheduled", { cron });
return new Response("Ran scheduled event");
}
const resp = await middlewareCtx.next(request, env);
// If you open the `/__scheduled` page in a browser, the browser will automatically make a request to `/favicon.ico`.
// For scheduled Workers _without_ a fetch handler, this will result in a 500 response that clutters the log with unhelpful error messages.
// To avoid this, inject a 404 response to favicon.ico loads on the `/__scheduled` page
if (
request.headers.get("referer")?.endsWith("/__scheduled") &&
url.pathname === "/favicon.ico" &&
resp.status === 500
) {
return new Response(null, { status: 404 });
}
return resp;
};
export default scheduled;