diff --git a/dist/components/proxy-middleware/middlewares/amiusing_middleware.js b/dist/components/proxy-middleware/middlewares/amiusing_middleware.js index 868bafa..2e6b5d8 100644 --- a/dist/components/proxy-middleware/middlewares/amiusing_middleware.js +++ b/dist/components/proxy-middleware/middlewares/amiusing_middleware.js @@ -1,16 +1,33 @@ "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", + // Echo the legacy request-side marker as a response header too so any + // downstream consumer that historically inspected `amiusingrequestly` + // continues to see it after we stopped forwarding upstream. + "amiusingrequestly": "true", + }); + 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/src/components/proxy-middleware/middlewares/amiusing_middleware.js b/src/components/proxy-middleware/middlewares/amiusing_middleware.js index e2a8ae5..9558588 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,19 @@ 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", + // Echo the legacy request-side marker as a response header too so any + // downstream consumer that historically inspected `amiusingrequestly` + // continues to see it after we stopped forwarding upstream. + "amiusingrequestly": "true", + }); + 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. +

+
+
+ +
+
+ +`;