#Cors blocking using Hono.js and workers

3 messages · Page 1 of 1 (latest)

rotund arrow
#

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.

#

Cors blocking using Hono.js and workers

#

I think that the blocking is happening before it reaches my application. Because when I remove the origin from http://localhost:3000 and try to access from localhost:3000 I have see the OPTIONS logs in the WORKER panel, but when I try to access from "https://develop.scheduling-next-front-end.pages.dev" I havent see the OPTIONS logs in the worker panel.

Is there any CORS blocking in Cloud Flare before it reaches my application?