Skip to content

Commit

Permalink
Add CORS middleware to /upload endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ifyour committed Apr 30, 2024
1 parent f7c11ab commit 3e81fe9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Hono } from "hono";
import { cors } from "hono/cors";
import { serveStatic } from "hono/cloudflare-workers";

const app = new Hono<{ Bindings: { API_HOST: string } }>();

app.get("/*", serveStatic({ root: "./" }));

app.post("/upload", async (c) => {
app.post("/upload", cors(), async (c) => {
const body = await c.req.parseBody();
const file = body.file as File;
const formData = new FormData();
Expand Down

0 comments on commit 3e81fe9

Please sign in to comment.