Skip to content

Instantly share code, notes, and snippets.

@homburg
Created March 21, 2023 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homburg/fdc049a0976896dc7dcac35023316356 to your computer and use it in GitHub Desktop.
Save homburg/fdc049a0976896dc7dcac35023316356 to your computer and use it in GitHub Desktop.
const suffix_length = ".l.jfjf.dk".length;
async function onRequest(context, url, request) {
const [fake_host, raw_port] = request.host.slice(0, -suffix_length).split("__");
let port = Number(raw_port);
if (!port || isNaN(port)) {
port = 443;
}
const host = fake_host.replaceAll("_", ".");
request.host = host;
request.port = port;
request.scheme = port === 443 ? "https" : "http";
return request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment