diff --git a/src/index.ts b/src/index.ts index 0e37b4b..f378ec5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,10 @@ import { Hono } from "hono"; import { handle } from "hono/aws-lambda"; import { compress } from "hono/compress"; +import { cors } from "hono/cors"; import { showRoutes } from "hono/dev"; -import { prettyJSON } from "hono/pretty-json"; import { logger } from "hono/logger"; +import { prettyJSON } from "hono/pretty-json"; import { WithId } from "mongodb"; import db from "./config/db"; import { getCarsByFuelType, getCOEResultByMonth } from "./lib"; @@ -11,6 +12,7 @@ import { Car, COEResult, FUEL_TYPE } from "./types"; const app = new Hono(); +app.use(cors()); app.use(logger()); app.use(compress()); app.use(prettyJSON()); diff --git a/sst.config.ts b/sst.config.ts index 118afbe..d7ed964 100644 --- a/sst.config.ts +++ b/sst.config.ts @@ -31,6 +31,7 @@ export default $config({ handler: "src/index.handler", url: { cors: { + allowOrigins: [`https://${DOMAIN_NAME}`], maxAge: "1 day", }, },