Skip to content

Commit

Permalink
add cors policy
Browse files Browse the repository at this point in the history
  • Loading branch information
instructr13 committed Oct 5, 2024
1 parent 0a73c9c commit cd0aa46
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/solver/src/features/ui-comm/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -17,6 +18,17 @@ export type Env = {
const app = new Hono<Env>();

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;
Expand Down

0 comments on commit cd0aa46

Please sign in to comment.