Commit 8f01c4f60b

8f01c4f60b5134b53f621398144c2eac69951afe

parent: 0720acdb7b

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-03-09 15:34 UTC

Fix CORS, allow for client-side and cross-origin GET requests

Layout: unified · split

api/src/api.ts +4
@@ -1,4 +1,5 @@
1import { Hono } from 'hono'; 1import { Hono } from 'hono';
2import { cors } from 'hono/cors';
2import Fuse from 'fuse.js'; 3import Fuse from 'fuse.js';
3 4
4import { 5import {
@@ -14,6 +15,9 @@ import index from '../public/index.html'
14/* Create new Hono app */ 15/* Create new Hono app */
15const app = new Hono({ strict: false }); 16const app = new Hono({ strict: false });
16 17
18/* Enable CORS for all routes */
19app.use('*', cors());
20
17/* Serve the index page (which contains the Swagger Docs) */ 21/* Serve the index page (which contains the Swagger Docs) */
18app.get("/", async (ctx) => { 22app.get("/", async (ctx) => {
19 if (index) { 23 if (index) {