Fetch inside a scheduled Cron Job

Hello,

I have a worker that I want to use to ping another worker endpoint every day.

When I run the dev server it works great but when I deploy I get 404.

Here's an example code block:

import { Env, Hono } from "hono";

const app = new Hono();

app.get("/", (c) => {
  return c.text("Hello Hono!");
});

export default {
  async scheduled(
    event: ScheduledEvent,
    env: Env,
    ctx: ExecutionContext
  ): Promise<void> {
    console.log("Scheduled Event Triggered at:", new Date().toISOString());

    const response = await fetch("example.worker.dev/my-endpoint");
  },

  async fetch(request: Request, env: Env) {
    return await app.fetch(request, env);
  },
};


Am I not using this right? I looked into ctx.waitUntil but that didn't help either.

Thank you!
Was this page helpful?