//index.ts
import { Hono } from "hono";
import { Bindings, Variables } from "./types";
import auth from "./utils/auth";
import { cors } from "hono/cors";
const app = new Hono<{
Bindings: Bindings;
Variables: Variables;
}>();
app.use(
"/api/auth/*", // or replace with "*" to enable cors for all routes
cors({
origin: "http://localhost:5173", // replace with your origin
allowHeaders: ["Content-Type", "Authorization"],
allowMethods: ["POST", "GET", "OPTIONS"],
exposeHeaders: ["Content-Length"],
maxAge: 6000,
credentials: true,
}),
);
app.on(["POST", "GET"], "/api/auth/*", (c) => {
return auth(c.env).handler(c.req.raw);
});
export default app;
//index.ts
import { Hono } from "hono";
import { Bindings, Variables } from "./types";
import auth from "./utils/auth";
import { cors } from "hono/cors";
const app = new Hono<{
Bindings: Bindings;
Variables: Variables;
}>();
app.use(
"/api/auth/*", // or replace with "*" to enable cors for all routes
cors({
origin: "http://localhost:5173", // replace with your origin
allowHeaders: ["Content-Type", "Authorization"],
allowMethods: ["POST", "GET", "OPTIONS"],
exposeHeaders: ["Content-Length"],
maxAge: 6000,
credentials: true,
}),
);
app.on(["POST", "GET"], "/api/auth/*", (c) => {
return auth(c.env).handler(c.req.raw);
});
export default app;