Cors blocking using Hono.js and workers

Im using Hono. I add the code above to allow localhost access to my worker, and its worker well.

app.use("*", async (c, next) => {
  const corsMiddleware = cors({
    origin: ["http://localhost:3000"],
    allowMethods: ["GET", "OPTIONS", "POST", "PUT", "DELETE"],
    credentials: true,
  });
  return corsMiddleware(c, next);
});

Now i trying use my next.js website deployed in the cloudFlare pages and i add cors policy:

app.use("*", async (c, next) => {
  const corsMiddleware = cors({
    origin: [
      "http://localhost:3000",
      "https://develop.scheduling-next-front-end.pages.dev",
    ],
    allowMethods: ["GET", "OPTIONS", "POST", "PUT", "DELETE"],
    credentials: true,
  });
  return corsMiddleware(c, next);
});

But its not working. And i received BLOCK BY CORS POLICY.
image.png
Was this page helpful?