chen90922 commited on
Commit
354898c
1 Parent(s): 4178c14

Create worker.js

Browse files
Files changed (1) hide show
  1. worker.js +18 -0
worker.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const TRAGET_HOST='chen90922-dfgtf.hf.space' // 请将此域名改成你自己的,域名信息在设置》站点域名查看。
2
+
3
+ export default {
4
+ async fetch(request) {
5
+ const uri = new URL(request.url);
6
+ if (uri.protocol === 'http:') {
7
+ uri.protocol = 'https:';
8
+ return new Response('', {
9
+ status: 301,
10
+ headers: {
11
+ location: uri.toString(),
12
+ },
13
+ })
14
+ }
15
+ uri.host = TRAGET_HOST
16
+ return fetch(new Request(uri.toString(), request));
17
+ },
18
+ };