From cd0aa4674f60968ad08fd696fdf7ed202b64b9af Mon Sep 17 00:00:00 2001 From: Mido Date: Sat, 5 Oct 2024 22:57:32 +0900 Subject: [PATCH] add cors policy --- apps/solver/src/features/ui-comm/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/solver/src/features/ui-comm/index.ts b/apps/solver/src/features/ui-comm/index.ts index ce891ef..4a5e31b 100644 --- a/apps/solver/src/features/ui-comm/index.ts +++ b/apps/solver/src/features/ui-comm/index.ts @@ -1,5 +1,6 @@ import type { Serve, Server } from "bun"; import { Hono } from "hono"; +import { cors } from "hono/cors"; import { showRoutes } from "hono/dev"; import { logger } from "hono/logger"; import { HOST, PORT, isDevelopment } from "../../constants/env.ts"; @@ -17,6 +18,17 @@ export type Env = { const app = new Hono(); app.use(logger()); +app.use( + cors({ + origin: (origin) => { + if (isDevelopment) { + return origin; + } + + return origin.endsWith("data-maki.pages.dev") ? origin : ""; + }, + }), +); export class UICommunicatorFeature extends FeatureBase { #server!: Server;