Skip to content

Commit

Permalink
Update index.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
threepointone committed Jul 31, 2024
1 parent 7a0c7ef commit 283c0da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion example/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export default {
async fetch(request, env) {
const url = new URL(request.url);

if (/^\/api\/chat\/[_\-A-Za-z]*/.exec(url.pathname)) {
if (
request.method === "POST" &&
/^\/api\/chat\/[_\-A-Za-z]*/.exec(url.pathname)
) {
const workersai = createWorkersAI({ binding: env.AI });
const { messages } = await request.json<{
messages: Parameters<typeof convertToCoreMessages>[0];
Expand Down

0 comments on commit 283c0da

Please sign in to comment.