From 6becf7d062a53469d6c03708438494ad537b2d78 Mon Sep 17 00:00:00 2001 From: Kevin Gorski Date: Wed, 13 Sep 2023 17:44:35 -0600 Subject: [PATCH] Attempting Clicky reverse-proxy --- deno.json | 3 +- fresh.gen.ts | 142 ++++++++++++++++++++-------------------- routes/335afc1fe2e63.ts | 20 ++++++ routes/_app.tsx | 2 +- static/56ac6c4e308a9.js | 1 + 5 files changed, 96 insertions(+), 72 deletions(-) create mode 100644 routes/335afc1fe2e63.ts create mode 100644 static/56ac6c4e308a9.js diff --git a/deno.json b/deno.json index 49843ec..9c3c2ee 100644 --- a/deno.json +++ b/deno.json @@ -38,7 +38,8 @@ "ulid": "https://deno.land/x/ulid@v0.2.2/mod.ts" }, "exclude": [ - "cov/" + "cov/", + "static/56ac6c4e308a9.js" ], "lint": { "rules": { diff --git a/fresh.gen.ts b/fresh.gen.ts index 2092ec2..6b18b9a 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -2,41 +2,42 @@ // This file SHOULD be checked into source version control. // This file is automatically updated during development when running `dev.ts`. -import * as $0 from "./routes/_404.tsx"; -import * as $1 from "./routes/_500.tsx"; -import * as $2 from "./routes/_app.tsx"; -import * as $3 from "./routes/_middleware.ts"; -import * as $4 from "./routes/about.tsx"; -import * as $5 from "./routes/account/_middleware.ts"; -import * as $6 from "./routes/account/connectOAuth.ts"; -import * as $7 from "./routes/account/delete.tsx"; -import * as $8 from "./routes/account/gitHubCallback.ts"; -import * as $9 from "./routes/account/index.tsx"; -import * as $10 from "./routes/account/manage.ts"; -import * as $11 from "./routes/account/sendVerificationEmail.ts"; -import * as $12 from "./routes/account/upgrade.ts"; -import * as $13 from "./routes/admin/_middleware.ts"; -import * as $14 from "./routes/admin/emailTemplates.tsx"; -import * as $15 from "./routes/admin/index.tsx"; -import * as $16 from "./routes/api/stripe-webhooks.ts"; -import * as $17 from "./routes/developerMagicLink.ts"; -import * as $18 from "./routes/employer/_middleware.ts"; -import * as $19 from "./routes/employer/delete.tsx"; -import * as $20 from "./routes/employer/index.tsx"; -import * as $21 from "./routes/employerCallback.ts"; -import * as $22 from "./routes/employerSignIn.tsx"; -import * as $23 from "./routes/gitHubCallback.ts"; -import * as $24 from "./routes/index.tsx"; -import * as $25 from "./routes/kv-insights/_middleware.ts"; -import * as $26 from "./routes/signInOAuth.ts"; -import * as $27 from "./routes/signin.tsx"; -import * as $28 from "./routes/signout.ts"; -import * as $29 from "./routes/start/developer/index.tsx"; -import * as $30 from "./routes/start/developer/thanks.tsx"; -import * as $31 from "./routes/start/employer/index.tsx"; -import * as $32 from "./routes/start/employer/thanks.tsx"; -import * as $33 from "./routes/start/index.tsx"; -import * as $34 from "./routes/verifyEmail.ts"; +import * as $0 from "./routes/335afc1fe2e63.ts"; +import * as $1 from "./routes/_404.tsx"; +import * as $2 from "./routes/_500.tsx"; +import * as $3 from "./routes/_app.tsx"; +import * as $4 from "./routes/_middleware.ts"; +import * as $5 from "./routes/about.tsx"; +import * as $6 from "./routes/account/_middleware.ts"; +import * as $7 from "./routes/account/connectOAuth.ts"; +import * as $8 from "./routes/account/delete.tsx"; +import * as $9 from "./routes/account/gitHubCallback.ts"; +import * as $10 from "./routes/account/index.tsx"; +import * as $11 from "./routes/account/manage.ts"; +import * as $12 from "./routes/account/sendVerificationEmail.ts"; +import * as $13 from "./routes/account/upgrade.ts"; +import * as $14 from "./routes/admin/_middleware.ts"; +import * as $15 from "./routes/admin/emailTemplates.tsx"; +import * as $16 from "./routes/admin/index.tsx"; +import * as $17 from "./routes/api/stripe-webhooks.ts"; +import * as $18 from "./routes/developerMagicLink.ts"; +import * as $19 from "./routes/employer/_middleware.ts"; +import * as $20 from "./routes/employer/delete.tsx"; +import * as $21 from "./routes/employer/index.tsx"; +import * as $22 from "./routes/employerCallback.ts"; +import * as $23 from "./routes/employerSignIn.tsx"; +import * as $24 from "./routes/gitHubCallback.ts"; +import * as $25 from "./routes/index.tsx"; +import * as $26 from "./routes/kv-insights/_middleware.ts"; +import * as $27 from "./routes/signInOAuth.ts"; +import * as $28 from "./routes/signin.tsx"; +import * as $29 from "./routes/signout.ts"; +import * as $30 from "./routes/start/developer/index.tsx"; +import * as $31 from "./routes/start/developer/thanks.tsx"; +import * as $32 from "./routes/start/employer/index.tsx"; +import * as $33 from "./routes/start/employer/thanks.tsx"; +import * as $34 from "./routes/start/index.tsx"; +import * as $35 from "./routes/verifyEmail.ts"; import * as $$0 from "./islands/Chart.tsx"; import * as $$1 from "./islands/DeleteAccountButton.tsx"; import * as $$2 from "./islands/EntriesManagement.tsx"; @@ -44,41 +45,42 @@ import * as $$3 from "./islands/VerifyEmailButton.tsx"; const manifest = { routes: { - "./routes/_404.tsx": $0, - "./routes/_500.tsx": $1, - "./routes/_app.tsx": $2, - "./routes/_middleware.ts": $3, - "./routes/about.tsx": $4, - "./routes/account/_middleware.ts": $5, - "./routes/account/connectOAuth.ts": $6, - "./routes/account/delete.tsx": $7, - "./routes/account/gitHubCallback.ts": $8, - "./routes/account/index.tsx": $9, - "./routes/account/manage.ts": $10, - "./routes/account/sendVerificationEmail.ts": $11, - "./routes/account/upgrade.ts": $12, - "./routes/admin/_middleware.ts": $13, - "./routes/admin/emailTemplates.tsx": $14, - "./routes/admin/index.tsx": $15, - "./routes/api/stripe-webhooks.ts": $16, - "./routes/developerMagicLink.ts": $17, - "./routes/employer/_middleware.ts": $18, - "./routes/employer/delete.tsx": $19, - "./routes/employer/index.tsx": $20, - "./routes/employerCallback.ts": $21, - "./routes/employerSignIn.tsx": $22, - "./routes/gitHubCallback.ts": $23, - "./routes/index.tsx": $24, - "./routes/kv-insights/_middleware.ts": $25, - "./routes/signInOAuth.ts": $26, - "./routes/signin.tsx": $27, - "./routes/signout.ts": $28, - "./routes/start/developer/index.tsx": $29, - "./routes/start/developer/thanks.tsx": $30, - "./routes/start/employer/index.tsx": $31, - "./routes/start/employer/thanks.tsx": $32, - "./routes/start/index.tsx": $33, - "./routes/verifyEmail.ts": $34, + "./routes/335afc1fe2e63.ts": $0, + "./routes/_404.tsx": $1, + "./routes/_500.tsx": $2, + "./routes/_app.tsx": $3, + "./routes/_middleware.ts": $4, + "./routes/about.tsx": $5, + "./routes/account/_middleware.ts": $6, + "./routes/account/connectOAuth.ts": $7, + "./routes/account/delete.tsx": $8, + "./routes/account/gitHubCallback.ts": $9, + "./routes/account/index.tsx": $10, + "./routes/account/manage.ts": $11, + "./routes/account/sendVerificationEmail.ts": $12, + "./routes/account/upgrade.ts": $13, + "./routes/admin/_middleware.ts": $14, + "./routes/admin/emailTemplates.tsx": $15, + "./routes/admin/index.tsx": $16, + "./routes/api/stripe-webhooks.ts": $17, + "./routes/developerMagicLink.ts": $18, + "./routes/employer/_middleware.ts": $19, + "./routes/employer/delete.tsx": $20, + "./routes/employer/index.tsx": $21, + "./routes/employerCallback.ts": $22, + "./routes/employerSignIn.tsx": $23, + "./routes/gitHubCallback.ts": $24, + "./routes/index.tsx": $25, + "./routes/kv-insights/_middleware.ts": $26, + "./routes/signInOAuth.ts": $27, + "./routes/signin.tsx": $28, + "./routes/signout.ts": $29, + "./routes/start/developer/index.tsx": $30, + "./routes/start/developer/thanks.tsx": $31, + "./routes/start/employer/index.tsx": $32, + "./routes/start/employer/thanks.tsx": $33, + "./routes/start/index.tsx": $34, + "./routes/verifyEmail.ts": $35, }, islands: { "./islands/Chart.tsx": $$0, diff --git a/routes/335afc1fe2e63.ts b/routes/335afc1fe2e63.ts new file mode 100644 index 0000000..ab72021 --- /dev/null +++ b/routes/335afc1fe2e63.ts @@ -0,0 +1,20 @@ +/* Reverse proxy for Clicky Beacon to enable analytics */ +import { HandlerContext, Handlers } from "$fresh/server.ts"; + +export const handler: Handlers = { + async GET(req: Request, ctx: HandlerContext) { + const { host, protocol, search } = new URL(req.url); + const proxiedUrl = new URL("https://in.getclicky.com/in.php"); + proxiedUrl.search = search; + + const headers = new Headers(); + headers.set("Host", proxiedUrl.hostname); + headers.set("X-Forwarded-Host", host); + headers.set("X-Forwarded-Proto", protocol); + headers.set("X-Forwarded-For", ctx.remoteAddr.hostname); + + return await fetch(proxiedUrl, { + headers, + }); + }, +}; diff --git a/routes/_app.tsx b/routes/_app.tsx index d1da034..e6dee65 100644 --- a/routes/_app.tsx +++ b/routes/_app.tsx @@ -36,7 +36,7 @@ export default function App(props: AppProps) { employerSessionId={props.data?.employerSessionId} sessionId={props.data?.sessionId} /> - diff --git a/static/56ac6c4e308a9.js b/static/56ac6c4e308a9.js new file mode 100644 index 0000000..b5cff32 --- /dev/null +++ b/static/56ac6c4e308a9.js @@ -0,0 +1 @@ +var clicky_obj=clicky_obj||(function(){var instance=null;function _ins(){var _self=this,site_ids=[],pageviews_fired=[],monitors=0,setup=0,ossassets=0,ossdata=0;this.domain='//in.getclicky.com';this.sitekeys=[];this.site_id_exists=function(site_id){for(var s in site_ids)if(site_ids[s]==site_id)return true;return false;};this.sitekey=function(site_id,key_only){if(_self.sitekeys&&_self.sitekeys[site_id])return(key_only?'':'&sitekey=')+_self.sitekeys[site_id];return'';};this.init=function(site_id){if(_self.site_id_exists(site_id))return;site_ids.push(site_id);if(clicky_custom.getHighEntropyValues&&navigator.userAgentData&&navigator.userAgentData.getHighEntropyValues){navigator.userAgentData.getHighEntropyValues(["model","platformVersion"]).then(function(ua){_self.he_model=ua.model;_self.he_platform=parseInt(ua.platformVersion);});}if(!setup){setup=1;setTimeout(_self.setup,200);}};this.setup=function(){if(location.hash.match(/^#_heatmap/))_self.heatmap();if(!_self.get_cookie('_first_pageview')){_self.set_referrer();}_self.start_monitors();if(!clicky_custom.pageview_disable)_self.pageview(1);};this.custom_data=function(){var data={},keys=['username','name','email'],l=keys.length;for(var i=0;i240)))return;_self.pinging=1;_self.ps_stop=clicky_custom.timeout?((clicky_custom.timeout*60)-120)+5:485;setTimeout(_self.ping,30000);setTimeout(_self.ping,60000);setTimeout(_self.ping_set,120000);};this.ping_set=function(){var pingy=setInterval(_self.ping,120000);setTimeout(function(){clearInterval(pingy);},_self.ps_stop*1000);_self.ping();};this.ping=function(){_self.beacon('ping');};this.get_cookie=function(name){if(clicky_custom.sticky_data_disable&&name.match(/^_(custom|utm|referrer)/))return'';var ca=document.cookie.split(';');for(var i=0,l=ca.length;i