Skip to content

Commit 85815d1

Browse files
committed
fix(cicd): added workflow and cors
1 parent a019369 commit 85815d1

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Deploy to Vercel
2+
3+
on:
4+
push:
5+
branches:
6+
- main # or whatever branch you deploy from
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
14+
- name: Setup Node
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: 18
18+
19+
- name: Install dependencies
20+
working-directory: ./client
21+
run: npm install
22+
23+
- name: Build
24+
working-directory: ./client
25+
run: npm run build
26+
27+
- name: Deploy with Vercel
28+
run: npx vercel --prod --token=${{ secrets.VERCEL_TOKEN }} --cwd=./client

backend/src/index.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Hono } from "hono";
22
import { logger } from "hono/logger";
3+
import { cors } from "hono/cors";
34
import { lokiLogger } from "./monitor/logger";
45
import { prometheus } from "@hono/prometheus";
56
import { otel } from "@hono/otel";
@@ -35,6 +36,33 @@ const PORT = process.env.PORT || 3000;
3536

3637
app.use(logger(lokiLogger));
3738

39+
// CORS configuration - allow all origins
40+
app.use(
41+
"*",
42+
cors({
43+
origin: "*", // Allow all origins
44+
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
45+
allowHeaders: [
46+
"Content-Type",
47+
"Authorization",
48+
"X-Requested-With",
49+
"Origin",
50+
"Accept",
51+
],
52+
credentials: false,
53+
})
54+
);
55+
56+
// Additional explicit OPTIONS handler for preflight requests
57+
app.options("*", (c) => {
58+
return c.text("", 200, {
59+
"Access-Control-Allow-Origin": "*",
60+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
61+
"Access-Control-Allow-Headers":
62+
"Content-Type, Authorization, X-Requested-With, Origin, Accept",
63+
});
64+
});
65+
3866
app.use("*", registerMetrics, otel());
3967
app.get("/metrics", printMetrics);
4068

0 commit comments

Comments
 (0)