Try this:```ts await ai.run('@cf/openai/whisper', { audio: [...new Uint8Array(await formData.get("
Try this:
await ai.run('@cf/openai/whisper', {
audio: [...new Uint8Array(await formData.get("audio").arrayBuffer())],
}); has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.Access-Control-Allow-Origin header?* if you don't care about CORS, and your app doesn't need anything else*router.post("/add", async (res, req) => { return CustomResponse(myJSONPayload, 200) })itty-router ?[sites] attribute in wrangler.toml then yes, they're charged since that uploads them to Workers KV but there's no size limit that way except for the KV per-value limit.hono was amazing than itty for the routing and cors issuectx.waitUntil is for exactly in context of BetterKV?waitUntil to ensure that it will keep running, even if you have returned a ResponsebKv.put revalidate values stored with the same key?cache.delete or maybe even cache.put does that for you (im testing that right now), but what about KV ?const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Max-Age': '86400', // optional
'Access-Control-Allow-Headers': 'Content-Type',
};
const CustomResponse = (body: any, status: number = 200) => {
return new Response(body, {
headers: {
...corsHeaders,
'Content-Type': 'application/json',
},
status,
});
};import { Router, createCors, error, json } from 'itty-router'
const { preflight, corsify } = createCors()
const router = Router()
router
// embed preflight upstream to handle all OPTIONS requests
.all('*', preflight)export const router = Router();
const { preflight, corsify } = createCors({
methods: ['GET', 'POST'],
origins: [
// Your origins that are okay here
]
});
router
.all('*', preflight)
.all('*', defaultRoutes.handle)
.all('*', () => error(404));cache.delete