fix(routes/api): handle non websocket connection
This commit is contained in:
parent
fba0c18aa8
commit
595b9518d5
|
|
@ -2,6 +2,15 @@ import { define } from '../../../utils.ts'
|
|||
|
||||
export const handler = define.handlers({
|
||||
GET(ctx) {
|
||||
if (
|
||||
ctx.req.headers.get('connection') !== 'Upgrade' &&
|
||||
ctx.req.headers.get('upgrade') !== 'websocket'
|
||||
) {
|
||||
return new Response('Request is not a websocket upgrade.', {
|
||||
status: 400,
|
||||
})
|
||||
}
|
||||
|
||||
const { response } = Deno.upgradeWebSocket(ctx.req)
|
||||
ctx.state.skipMiddlewares = true
|
||||
return response
|
||||
|
|
|
|||
Loading…
Reference in a new issue