有很多反馈说heroku被秒封!建议先用其他的heroku项目或先避开当前的敏感期
请勿fork,请勿fork,请勿fork
直接点击绿色的Use this template
创建自己名称的项目,workers反代与pages反代及自定义域相关操作拓展教程,请关注:博客视频教程
CloudFlare Workers单账户反代代码
addEventListener(
"fetch",event => {
let url=new URL(event.request.url);
url.hostname="appname.herokuapp.com";
let request=new Request(url,event.request);
event. respondWith(
fetch(request)
)
}
)
CloudFlare Workers单双日轮换反代代码
const SingleDay = 'app0.herokuapp.com'
const DoubleDay = 'app1.herokuapp.com'
addEventListener(
"fetch",event => {
let nd = new Date();
if (nd.getDate()%2) {
host = SingleDay
} else {
host = DoubleDay
}
let url=new URL(event.request.url);
url.hostname=host;
let request=new Request(url,event.request);
event. respondWith(
fetch(request)
)
}
)
CloudFlare Workers每五天轮换一遍式反代代码
const Day0 = 'app0.herokuapp.com'
const Day1 = 'app1.herokuapp.com'
const Day2 = 'app2.herokuapp.com'
const Day3 = 'app3.herokuapp.com'
const Day4 = 'app4.herokuapp.com'
addEventListener(
"fetch",event => {
let nd = new Date();
let day = nd.getDate() % 5;
if (day === 0) {
host = Day0
} else if (day === 1) {
host = Day1
} else if (day === 2) {
host = Day2
} else if (day === 3){
host = Day3
} else if (day === 4){
host = Day4
} else {
host = Day1
}
let url=new URL(event.request.url);
url.hostname=host;
let request=new Request(url,event.request);
event. respondWith(
fetch(request)
)
}
)
CloudFlare Workers一周轮换反代代码
const Day0 = 'app0.herokuapp.com'
const Day1 = 'app1.herokuapp.com'
const Day2 = 'app2.herokuapp.com'
const Day3 = 'app3.herokuapp.com'
const Day4 = 'app4.herokuapp.com'
const Day5 = 'app5.herokuapp.com'
const Day6 = 'app6.herokuapp.com'
addEventListener(
"fetch",event => {
let nd = new Date();
let day = nd.getDay();
if (day === 0) {
host = Day0
} else if (day === 1) {
host = Day1
} else if (day === 2) {
host = Day2
} else if (day === 3){
host = Day3
} else if (day === 4) {
host = Day4
} else if (day === 5) {
host = Day5
} else if (day === 6) {
host = Day6
} else {
host = Day1
}
let url=new URL(event.request.url);
url.hostname=host;
let request=new Request(url,event.request);
event. respondWith(
fetch(request)
)
}
)