Skip to content

Commit d51d618

Browse files
committed
fix: skip CORS for WebSocket routes (#703)
1 parent 365de24 commit d51d618

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/actor-core/src/actor/runtime/actor_router.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ export function createActorRouter(
8383

8484
// Apply CORS middleware if configured
8585
if (config.cors) {
86-
app.use("*", cors(config.cors));
86+
app.use("*", async (c, next) => {
87+
const path = c.req.path;
88+
89+
// Don't apply to WebSocket routes, see https://hono.dev/docs/helpers/websocket#upgradewebsocket
90+
if (path === "/connect/websocket" || path === "/inspect") {
91+
return next();
92+
}
93+
94+
return cors(config.cors)(c, next);
95+
});
8796
}
8897

8998
app.get("/", (c) => {

0 commit comments

Comments
 (0)