Skip to content

Commit

Permalink
修复CF worker代理问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tech-shrimp committed Jan 7, 2025
1 parent 1428cbf commit ac18d58
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ const assetManifest = {};
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);

// 处理 WebSocket 连接
if (request.headers.get('Upgrade') === 'websocket') {
return handleWebSocket(request, env);
}

// 处理静态资源
if (url.pathname === '/' || url.pathname === '/index.html') {
Expand All @@ -25,10 +30,7 @@ export default {
});
}

// 处理 WebSocket 连接
if (request.headers.get('Upgrade') === 'websocket') {
return handleWebSocket(request, env);
}


return new Response('Not found', { status: 404 });
},
Expand Down

0 comments on commit ac18d58

Please sign in to comment.