Skip to content

Commit f411cf5

Browse files
fix(local): return null from CORS origin callback for non-localhost origins
Returning a mismatched string still worked (browser blocks on mismatch) but returning null correctly omits the Access-Control-Allow-Origin header per Hono's CORS middleware API.
1 parent 16731e3 commit f411cf5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/commands/local.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function buildApp(
115115
"*",
116116
cors({
117117
origin: (origin) =>
118-
LOCALHOST_ORIGIN_RE.test(origin) ? origin : "http://localhost",
118+
LOCALHOST_ORIGIN_RE.test(origin) ? origin : null,
119119
allowMethods: ["GET", "POST", "OPTIONS"],
120120
allowHeaders: ["Content-Type", "Content-Encoding", "User-Agent"],
121121
})

0 commit comments

Comments
 (0)