Skip to content

Commit

Permalink
Encode headers
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ckoates committed Jul 2, 2024
1 parent bedee9e commit a9f05b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/api/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export async function POST(request: Request) {

return new Response(voice.body, {
headers: {
"X-Transcript": transcript,
"X-Response": response,
"X-Transcript": encodeURIComponent(transcript),
"X-Response": encodeURIComponent(response),
},
});
}
Expand Down
8 changes: 6 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ export default function Home() {
body: formData,
});

const transcript = response.headers.get("X-Transcript");
const text = response.headers.get("X-Response");
const transcript = decodeURIComponent(
response.headers.get("X-Transcript") || ""
);
const text = decodeURIComponent(
response.headers.get("X-Response") || ""
);

if (!response.ok || !transcript || !text || !response.body) {
const error =
Expand Down

0 comments on commit a9f05b2

Please sign in to comment.