Skip to content

Commit

Permalink
fix: 301
Browse files Browse the repository at this point in the history
  • Loading branch information
weaigc committed Aug 7, 2023
1 parent c25bad3 commit 2a29b78
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cloudflare/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ const TRAGET_HOST='hf4all-bingo.hf.space' // 请将此域名改成你自己的
export default {
async fetch(request) {
const uri = new URL(request.url);
if (uri.protocol === 'http:') {
uri.protocol = 'https:';
return new Response('', {
status: 301,
headers: {
location: uri.toString(),
},
})
}
uri.host = TRAGET_HOST
return fetch(new Request(uri.toString(), request));
},
Expand Down

0 comments on commit 2a29b78

Please sign in to comment.