diff --git a/functions/util.ts b/functions/util.ts index 1ee4665..b1ee6ec 100644 --- a/functions/util.ts +++ b/functions/util.ts @@ -33,4 +33,11 @@ const index401 = ` `; -export { index401 }; +const page404 = ` + + +

404

There's nothing here.
Take me home
+ +`; + +export { index401, page404 }; diff --git a/functions/vless.ts b/functions/vless.ts index cc4be29..4c5f375 100644 --- a/functions/vless.ts +++ b/functions/vless.ts @@ -4,6 +4,7 @@ import { vlessJs, } from 'vless-js'; import { connect } from 'cloudflare:sockets'; +import { page404 } from './util'; interface Env { KV: KVNamespace; @@ -21,8 +22,12 @@ export const onRequest: PagesFunction = async (context) => { const upgradeHeader = context.request.headers.get('Upgrade'); if (!upgradeHeader || upgradeHeader !== 'websocket') { - return new Response(`Expected Upgrade: websocket`, { - status: 404, + return new Response(``, { + status: 401, + headers: { + 'content-type': 'text/html; charset=utf-8', + 'WWW-Authenticate': 'Basic', + }, }); }