From 7ad2da6a58ebc26f9ba68aabb69d9f83b1502fb1 Mon Sep 17 00:00:00 2001 From: dinex-dev Date: Thu, 14 May 2026 17:06:41 +0530 Subject: [PATCH] feat: serve amiusing.requestly.io response inline from the proxy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the existing AmisuingMiddleware header-injection behaviour with a direct response substitution: when a request hits amiusing.requestly.io, the proxy writes a self-contained "Success" HTML page back to the client and never forwards upstream. The page mirrors the existing amiusing.requestly.io two-column "Yes" design (Success column + What's next doc links) and carries a JSON marker (`{"amiusing": true}`) for programmatic detection. This runs as a pre-rules middleware (registered via init_amiusing_handler), so it short-circuits before the rule engine is consulted — the same pattern ssl_cert_middleware uses for /ssl certificate downloads. It does not depend on the rule system or on any desktop-app side changes beyond a dep bump. Effect: with this proxy version installed, any client routed through the desktop proxy that hits amiusing.requestly.io sees the Success page, independent of what the origin currently serves. Once the origin migrates to a static "No" page, only stale proxies still depend on the origin path. The HTML body is extracted to amiusing_yes_page.js to keep the middleware file focused on routing/handler logic. Bumps version to 1.3.15. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../middlewares/amiusing_middleware.js | 21 +++- .../middlewares/amiusing_yes_page.d.ts | 1 + .../middlewares/amiusing_yes_page.js | 103 ++++++++++++++++++ package.json | 2 +- .../middlewares/amiusing_middleware.js | 24 +++- .../middlewares/amiusing_yes_page.js | 101 +++++++++++++++++ 6 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 dist/components/proxy-middleware/middlewares/amiusing_yes_page.d.ts create mode 100644 dist/components/proxy-middleware/middlewares/amiusing_yes_page.js create mode 100644 src/components/proxy-middleware/middlewares/amiusing_yes_page.js diff --git a/dist/components/proxy-middleware/middlewares/amiusing_middleware.js b/dist/components/proxy-middleware/middlewares/amiusing_middleware.js index 868bafa..c31d05b 100644 --- a/dist/components/proxy-middleware/middlewares/amiusing_middleware.js +++ b/dist/components/proxy-middleware/middlewares/amiusing_middleware.js @@ -1,16 +1,29 @@ "use strict"; +// Synthesizes a "Success" page for amiusing.requestly.io entirely inside the +// proxy, without forwarding upstream. This proves to the user that traffic is +// flowing through the Requestly desktop proxy, regardless of what the origin +// at amiusing.requestly.io is currently serving. +// +// Runs as a pre-rules middleware (registered via init_amiusing_handler), so it +// short-circuits before the rule engine is consulted — the same pattern +// ssl_cert_middleware uses for /ssl certificate downloads. Object.defineProperty(exports, "__esModule", { value: true }); +const amiusing_yes_page_1 = require("./amiusing_yes_page"); +const AMIUSING_HOST = "amiusing.requestly.io"; class AmisuingMiddleware { constructor(is_active) { this.on_request = async (ctx) => { if (!this.is_active) { return true; } - if (ctx.proxyToServerRequestOptions.host === "amiusing.requestly.io") { - Object.assign(ctx.proxyToServerRequestOptions.headers, { - ["amiusingrequestly"]: "true", - }); + if (ctx.proxyToServerRequestOptions.host !== AMIUSING_HOST) { + return; } + ctx.proxyToClientResponse.writeHead(200, { + "Content-Type": "text/html", + "Cache-Control": "no-store", + }); + ctx.proxyToClientResponse.end(amiusing_yes_page_1.AMIUSING_YES_HTML); }; this.is_active = is_active; } diff --git a/dist/components/proxy-middleware/middlewares/amiusing_yes_page.d.ts b/dist/components/proxy-middleware/middlewares/amiusing_yes_page.d.ts new file mode 100644 index 0000000..2ea1258 --- /dev/null +++ b/dist/components/proxy-middleware/middlewares/amiusing_yes_page.d.ts @@ -0,0 +1 @@ +export const AMIUSING_YES_HTML: "\n\n\n \n \n Am I Using Requestly | Requestly - Intercept & Modify HTTP(s) Requests\n \n \n \n \n\n\n
\n
\n
\n

\n \n \n \n \n \n \n \n \n \n Success\n

\n
\n

Your internet traffic is now successfully being transferred through Requestly.

\n

\n In case you're having trouble accessing HTTPS Website, refer to our troubleshooting guide\n here.\n

\n
\n
\n \n
\n
\n\n"; diff --git a/dist/components/proxy-middleware/middlewares/amiusing_yes_page.js b/dist/components/proxy-middleware/middlewares/amiusing_yes_page.js new file mode 100644 index 0000000..0b54185 --- /dev/null +++ b/dist/components/proxy-middleware/middlewares/amiusing_yes_page.js @@ -0,0 +1,103 @@ +"use strict"; +// Inlined "Success" page served by AmisuingMiddleware when a request to +// amiusing.requestly.io flows through the Requestly desktop proxy. Mirrors +// the existing two-column amiusing.requestly.io "Yes" design. +Object.defineProperty(exports, "__esModule", { value: true }); +exports.AMIUSING_YES_HTML = void 0; +exports.AMIUSING_YES_HTML = ` + + + + + Am I Using Requestly | Requestly - Intercept & Modify HTTP(s) Requests + + + + + + +
+
+
+

+ + + + + + + + + + Success +

+
+

Your internet traffic is now successfully being transferred through Requestly.

+

+ In case you're having trouble accessing HTTPS Website, refer to our troubleshooting guide + here. +

+
+
+ +
+
+ +`; diff --git a/package.json b/package.json index 36794b4..3b4bdc4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@requestly/requestly-proxy", - "version": "1.3.14", + "version": "1.3.15", "description": "Proxy that gives superpowers to all the Requestly clients", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/components/proxy-middleware/middlewares/amiusing_middleware.js b/src/components/proxy-middleware/middlewares/amiusing_middleware.js index e2a8ae5..cad7773 100644 --- a/src/components/proxy-middleware/middlewares/amiusing_middleware.js +++ b/src/components/proxy-middleware/middlewares/amiusing_middleware.js @@ -1,3 +1,16 @@ +// Synthesizes a "Success" page for amiusing.requestly.io entirely inside the +// proxy, without forwarding upstream. This proves to the user that traffic is +// flowing through the Requestly desktop proxy, regardless of what the origin +// at amiusing.requestly.io is currently serving. +// +// Runs as a pre-rules middleware (registered via init_amiusing_handler), so it +// short-circuits before the rule engine is consulted — the same pattern +// ssl_cert_middleware uses for /ssl certificate downloads. + +import { AMIUSING_YES_HTML } from "./amiusing_yes_page"; + +const AMIUSING_HOST = "amiusing.requestly.io"; + class AmisuingMiddleware { constructor(is_active) { this.is_active = is_active; @@ -8,12 +21,15 @@ class AmisuingMiddleware { return true; } - if(ctx.proxyToServerRequestOptions.host === "amiusing.requestly.io") { - Object.assign(ctx.proxyToServerRequestOptions.headers, { - ["amiusingrequestly"]: "true", - }); + if (ctx.proxyToServerRequestOptions.host !== AMIUSING_HOST) { + return; } + ctx.proxyToClientResponse.writeHead(200, { + "Content-Type": "text/html", + "Cache-Control": "no-store", + }); + ctx.proxyToClientResponse.end(AMIUSING_YES_HTML); }; } diff --git a/src/components/proxy-middleware/middlewares/amiusing_yes_page.js b/src/components/proxy-middleware/middlewares/amiusing_yes_page.js new file mode 100644 index 0000000..aa5305d --- /dev/null +++ b/src/components/proxy-middleware/middlewares/amiusing_yes_page.js @@ -0,0 +1,101 @@ +// Inlined "Success" page served by AmisuingMiddleware when a request to +// amiusing.requestly.io flows through the Requestly desktop proxy. Mirrors +// the existing two-column amiusing.requestly.io "Yes" design. + +export const AMIUSING_YES_HTML = ` + + + + + Am I Using Requestly | Requestly - Intercept & Modify HTTP(s) Requests + + + + + + +
+
+
+

+ + + + + + + + + + Success +

+
+

Your internet traffic is now successfully being transferred through Requestly.

+

+ In case you're having trouble accessing HTTPS Website, refer to our troubleshooting guide + here. +

+
+
+ +
+
+ +`;