Skip to content

Commit 4041b78

Browse files
committed
Enable cors
1 parent cfb49a5 commit 4041b78

File tree

1 file changed

+134
-26
lines changed

1 file changed

+134
-26
lines changed

app/worker.tsx

Lines changed: 134 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Hono } from "hono";
2+
import { cors } from "hono/cors";
23
import type { Fetcher } from "@cloudflare/workers-types";
34
import type { ApiData } from "./schemas";
45

@@ -8,6 +9,7 @@ interface Env {
89

910
// Create a typed Hono app
1011
const app = new Hono<{ Bindings: Env }>();
12+
app.use("*", cors());
1113

1214
// Root route
1315
app.get("/", async (c) => {
@@ -27,15 +29,36 @@ app.get("/", async (c) => {
2729
<html>
2830
<head>
2931
<title>Models.dev &mdash; An open-source database of AI models</title>
30-
<meta name="description" content="Models.dev is a comprehensive open-source database of AI model specifications, pricing, and features." />
31-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
32+
<meta
33+
name="description"
34+
content="Models.dev is a comprehensive open-source database of AI model specifications, pricing, and features."
35+
/>
36+
<meta
37+
name="viewport"
38+
content="width=device-width, initial-scale=1.0"
39+
/>
3240
<link rel="preconnect" href="https://fonts.googleapis.com" />
33-
<link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
34-
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Rubik:wght@300..900&display=swap" rel="stylesheet" />
41+
<link
42+
rel="preconnect"
43+
href="https://fonts.gstatic.com"
44+
crossOrigin="anonymous"
45+
/>
46+
<link
47+
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&family=Rubik:wght@300..900&display=swap"
48+
rel="stylesheet"
49+
/>
3550
<script src="/index.js"></script>
3651
<link rel="stylesheet" href="/index.css" />
37-
<link rel="icon" href="/favicon.svg" sizes="any" type="image/svg+xml" />
38-
<meta property="og:image" content="https://models.dev/social-share.png" />
52+
<link
53+
rel="icon"
54+
href="/favicon.svg"
55+
sizes="any"
56+
type="image/svg+xml"
57+
/>
58+
<meta
59+
property="og:image"
60+
content="https://models.dev/social-share.png"
61+
/>
3962
</head>
4063
<body>
4164
<header>
@@ -45,12 +68,30 @@ app.get("/", async (c) => {
4568
<p>An open-source database of AI models</p>
4669
</div>
4770
<div class="right">
48-
<a class="github" target="_blank" rel="noopener noreferrer" href="https://github.com/sst/models.dev">
49-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
50-
<path fill="currentColor" d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"></path>
71+
<a
72+
class="github"
73+
target="_blank"
74+
rel="noopener noreferrer"
75+
href="https://github.com/sst/models.dev"
76+
>
77+
<svg
78+
xmlns="http://www.w3.org/2000/svg"
79+
width="24"
80+
height="24"
81+
viewBox="0 0 24 24"
82+
>
83+
<path
84+
fill="currentColor"
85+
d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33s1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2"
86+
></path>
5187
</svg>
5288
</a>
53-
<input type="text" id="searchInput" onkeyup="filterTable()" placeholder="Filter by provider or model..." />
89+
<input
90+
type="text"
91+
id="searchInput"
92+
onkeyup="filterTable()"
93+
placeholder="Filter by provider or model..."
94+
/>
5495
<button id="btnHowToUse">How to use</button>
5596
</div>
5697
</header>
@@ -106,40 +147,107 @@ app.get("/", async (c) => {
106147
<div class="header">
107148
<h2>How to use</h2>
108149
<button id="btnClose">
109-
<svg xmlns="http://www.w3.org/2000/svg"
110-
viewBox="0 0 24 24"
111-
>
112-
<line x1="18" y1="6" x2="6" y2="18"
150+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
151+
<line
152+
x1="18"
153+
y1="6"
154+
x2="6"
155+
y2="18"
113156
stroke="currentColor"
114157
stroke-width="2"
115-
stroke-linecap="round" />
116-
<line x1="6" y1="6" x2="18" y2="18"
158+
stroke-linecap="round"
159+
/>
160+
<line
161+
x1="6"
162+
y1="6"
163+
x2="18"
164+
y2="18"
117165
stroke="currentColor"
118166
stroke-width="2"
119-
stroke-linecap="round" />
167+
stroke-linecap="round"
168+
/>
120169
</svg>
121170
</button>
122171
</div>
123172
<div class="body">
124-
<p><a href="/">Models.dev</a> is a comprehensive open-source database of AI model specifications, pricing, and features.</p>
125-
<p>There&apos;s no single database with information about all the available AI models. We started Models.dev as a community-contributed project to address this. We also use it internally in <a href="https://opencode.ai" target="_blank" rel="noopener noreferrer">opencode</a>.</p>
173+
<p>
174+
<a href="/">Models.dev</a> is a comprehensive open-source
175+
database of AI model specifications, pricing, and features.
176+
</p>
177+
<p>
178+
There&apos;s no single database with information about all the
179+
available AI models. We started Models.dev as a
180+
community-contributed project to address this. We also use it
181+
internally in{" "}
182+
<a
183+
href="https://opencode.ai"
184+
target="_blank"
185+
rel="noopener noreferrer"
186+
>
187+
opencode
188+
</a>
189+
.
190+
</p>
126191
<h2>API</h2>
127192
<p>You can access this data through an API.</p>
128193
<div class="code-block">
129-
<code>curl <a href="/api.json">https://models.dev/api.json</a></code>
194+
<code>
195+
curl <a href="/api.json">https://models.dev/api.json</a>
196+
</code>
130197
</div>
131-
<p>Use the <b>Model ID</b> field to do a lookup on any model; it&apos;s the identifier used by <a href="https://ai-sdk.dev/" target="_blank" rel="noopener noreferrer">AI SDK</a>.</p>
198+
<p>
199+
Use the <b>Model ID</b> field to do a lookup on any model;
200+
it&apos;s the identifier used by{" "}
201+
<a
202+
href="https://ai-sdk.dev/"
203+
target="_blank"
204+
rel="noopener noreferrer"
205+
>
206+
AI SDK
207+
</a>
208+
.
209+
</p>
132210
<h2>Contribute</h2>
133-
<p>The data is stored in the <a href="https://github.com/sst/models.dev" target="_blank" rel="noopener noreferrer">GitHub repo</a> as TOML files; organized by provider and model. This is used to generate this page and power the API.</p>
134-
<p>We need your help keeping this up to date. Feel free to edit the data and submit a pull request. Refer to the <a href="https://github.com/sst/models.dev/blob/dev/README.md">README</a> for more information.</p>
211+
<p>
212+
The data is stored in the{" "}
213+
<a
214+
href="https://github.com/sst/models.dev"
215+
target="_blank"
216+
rel="noopener noreferrer"
217+
>
218+
GitHub repo
219+
</a>{" "}
220+
as TOML files; organized by provider and model. This is used to
221+
generate this page and power the API.
222+
</p>
223+
<p>
224+
We need your help keeping this up to date. Feel free to edit the
225+
data and submit a pull request. Refer to the{" "}
226+
<a href="https://github.com/sst/models.dev/blob/dev/README.md">
227+
README
228+
</a>{" "}
229+
for more information.
230+
</p>
135231
</div>
136232
<div class="footer">
137-
<a href="https://github.com/sst/models.dev" target="_blank" rel="noopener noreferrer">Edit on GitHub</a>
138-
<a href="https://sst.dev" target="_blank" rel="noopener noreferrer">Created by SST</a>
233+
<a
234+
href="https://github.com/sst/models.dev"
235+
target="_blank"
236+
rel="noopener noreferrer"
237+
>
238+
Edit on GitHub
239+
</a>
240+
<a
241+
href="https://sst.dev"
242+
target="_blank"
243+
rel="noopener noreferrer"
244+
>
245+
Created by SST
246+
</a>
139247
</div>
140248
</dialog>
141249
</body>
142-
</html >
250+
</html>
143251
);
144252
} catch (err) {
145253
const error = err instanceof Error ? err : new Error(String(err));

0 commit comments

Comments
 (0)