Skip to content

Commit

Permalink
fix: /api/chat on Netlify Edge Functions
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Nov 7, 2023
1 parent 7b184bd commit 216c261
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async (request) => {
});


const headers = new Headers(res.response.headers)
const headers = new Headers(res?.response?.headers ?? {}) // can't access headers in newer version
headers.set("content-type", "text/plain")

return new Response(stream, { headers });
Expand Down
5 changes: 5 additions & 0 deletions api/importmap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"imports": {
"openai": "https://deno.land/x/[email protected]/mod.ts"
}
}
3 changes: 2 additions & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[build]
publish = "static"
command = "bun run build & bun run ssg"
edge_functions = "api"

[functions]
directory = "api"
deno_import_map = "./api/importmap.json"

[[redirects]]
from = "/api/*"
Expand Down

1 comment on commit 216c261

@vercel
Copy link

@vercel vercel bot commented on 216c261 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.