Skip to content

Commit

Permalink
tmp: add test proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 19, 2023
1 parent 3113f5d commit 8939bcd
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/chat-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function ChatPanel({
if (input) {
setFocus()
}
}, [input])
}, [input, setFocus])

return (
<form
Expand Down
2 changes: 1 addition & 1 deletion src/components/chat-suggestions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function ChatSuggestions({ setInput, suggestions = [] }: ChatSuggestionsP
useMemo(() => {
setSuggestions(suggestions)
window.scrollBy(0, 2000)
}, [suggestions.length])
}, [suggestions.length, setSuggestions])

return currentSuggestions?.length ? (
<div className="py-6">
Expand Down
2 changes: 1 addition & 1 deletion src/components/voice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Voice = ({ setInput, input, sendMessage, isSpeaking }: Pick<ReturnType<typ
setInput(input + msg)
}
}
}, [input])
}, [input, setInput, sendMessage])

const switchSR = (enable: boolean = false) => {
setListen(enable)
Expand Down
12 changes: 8 additions & 4 deletions src/pages/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (!url) {
return res.end('ok')
}
const response = await fetch(url, { headers, method, body })
.then((res) => res.text())

res.end(response)
const response = await fetch(url, { headers, method, body, redirect: 'manual' })
const text = await response.text()
res.writeHead(200, {
'Content-Type': 'application/text',
'x-url': response.url,
'x-status': response.status,
})
res.end(text)
} catch (e) {
console.log(e)
return res.end(e)
Expand Down

0 comments on commit 8939bcd

Please sign in to comment.