Skip to content

Commit 64a8c17

Browse files
committed
add node server example and CORS headers
1 parent 6664a43 commit 64a8c17

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"demo:react": "pnpm -C apps/react/demo dev",
1313
"storybook:react": "pnpm -C apps/react/storybook dev",
1414
"docs": "pnpm -C apps/docs dev",
15+
"server:node": "pnpm -C apps/node dev",
1516
"lint": "turbo run lint",
1617
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
1718
"check-types": "turbo run check-types",

packages/runtime/src/endpoint.ts

Lines changed: 9 additions & 0 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 { CopilotRuntime } from "./runtime";
34
import { handleRunAgent } from "./handlers/handle-run";
45
import { handleGetRuntimeInfo } from "./handlers/get-runtime-info";
@@ -30,6 +31,14 @@ export function createCopilotEndpoint({
3031

3132
return app
3233
.basePath(basePath)
34+
.use(
35+
"*",
36+
cors({
37+
origin: "*",
38+
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
39+
allowHeaders: ["*"],
40+
})
41+
)
3342
.use("*", async (c, next) => {
3443
const request = c.req.raw;
3544
const path = c.req.path;

pnpm-lock.yaml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ packages:
33
- "apps/docs"
44
- "apps/react/*"
55
- "apps/angular/*"
6+
- "apps/node"

0 commit comments

Comments
 (0)