export default { async fetch(request) { const url = new URL(request.url); let newUrl; if (url.hostname === "auth.rlxl.ink") { // Substitui o path: /rlxl.ink/oauth2/token → /auth.appypay.co.ao/oauth2/token const newPath = url.pathname.replace("/rlxl.ink/", "/auth.appypay.co.ao/"); newUrl = new URL("https://login.microsoftonline.com" + newPath + url.search); } else if (url.hostname === "gwy-api.rlxl.ink") { newUrl = new URL("https://gwy-api.appypay.co.ao" + url.pathname + url.search); } else if (url.hostname === "gwy-api-tst.rlxl.ink") { newUrl = new URL("https://gwy-api-tst.appypay.co.ao" + url.pathname + url.search); } else { return new Response("Not found", { status: 404 }); } const newRequest = new Request(newUrl.toString(), { method: request.method, headers: request.headers, body: ["GET", "HEAD"].includes(request.method) ? null : request.body, }); return fetch(newRequest); } };