Skip to content

Commit 248bb11

Browse files
committed
feat: add cors config
1 parent 65c9f90 commit 248bb11

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

bun.lockb

100644100755
8.24 KB
Binary file not shown.

src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Hono } from "hono";
2+
import { cors } from "hono/cors";
23
import { getCookie } from "hono/cookie";
34
import { createClient } from "redis";
45

@@ -16,11 +17,18 @@ type TModel = {
1617
};
1718

1819
const app = new Hono();
20+
app.use(
21+
"*",
22+
cors({
23+
origin: "*",
24+
credentials: true,
25+
}),
26+
);
1927

2028
const create = (userId: string, value: TModel) => {
2129
client.set(
2230
`${userId}:${value.method}:${value.path}`,
23-
JSON.stringify({ status: value.status, data: value.data })
31+
JSON.stringify({ status: value.status, data: value.data }),
2432
);
2533
};
2634

@@ -36,7 +44,7 @@ const clear = async (userId: string) => {
3644
const get = (
3745
userId: string,
3846
method: string,
39-
path: string
47+
path: string,
4048
): ReturnType<typeof client.get> => {
4149
return client.get(`${userId}:${method}:${path}`);
4250
};

0 commit comments

Comments
 (0)