Skip to content

Instantly share code, notes, and snippets.

View GoatAL0's full-sized avatar
🎯
Focusing

Goat AL GoatAL0

🎯
Focusing
View GitHub Profile
@GoatAL0
GoatAL0 / workerCloudflare
Last active February 16, 2023 22:57
Worker related code in cloudflare
export default {
async fetch(req) {
try {
const url = new URL(req.url);
const splitted = url.pathname.replace(/^\/*/, '').split('/');
const address = splitted[0];
url.pathname = splitted.slice(1).join('/');
url.hostname = address;
url.protocol = 'https';
return fetch(new Request(url, req));