Back

Version 33

8/25/2024
/** @jsxImportSource npm:hono@3/jsx */
import CryptoJS from "npm:crypto-js";
import { Hono } from "npm:hono";
const files = [
{
fileName: "data.js",
fileExt: "application/javascript+module",
fileContent: `export default {
name: "Example API",
tags: ["example", "api", "response"],
};`,
},
{
fileName: "index.js",
fileExt: "application/javascript+module",
fileContent: `export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
// CORS headers
const headers = {
"Access-Control-Allow-Origin": "https://rool-dev-guy.github.io", // Replace with your client origin
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Allow-Credentials": "true", // Allow credentials (cookies, authorization headers)
"Access-Control-Max-Age": "86400" // Cache the preflight response for 1 day
};

// Handle preflight OPTIONS request
if (request.method === "OPTIONS") {
return new Response("hellow this worked", {
status: 204,
headers
});
}

tempdev-workers.web.val.run
Updated: September 7, 2024