~udia/udia.ca

1b1583e7342b0f1612ce70a1cd248220f9c2753f — Alexander Wong 7 months ago b641c39
trying out function to proxy cf analytics script
4 files changed, 25 insertions(+), 1 deletions(-)

A functions/analytics.ts
M package.json
A tsconfig.json
M yarn.lock
A functions/analytics.ts => functions/analytics.ts +4 -0
@@ 0,0 1,4 @@
export const onRequest = async (_context) => {
  // const { data, env, next, params, request, waitUntil } = context;
  return fetch('https://static.cloudflareinsights.com/beacon.min.js')
}

M package.json => package.json +3 -1
@@ 23,7 23,9 @@
    "hexo-renderer-marked": "^4.1.0"
  },
  "devDependencies": {
    "@cloudflare/workers-types": "^3.2.0",
    "hexo-browsersync": "^0.3.0",
    "hexo-server": "^2.0.0"
    "hexo-server": "^2.0.0",
    "typescript": "^4.5.2"
  }
}

A tsconfig.json => tsconfig.json +8 -0
@@ 0,0 1,8 @@
{
    "compilerOptions": {
      "target": "ES2020",
      "module": "CommonJS",
      "lib": ["ES2020"],
      "types": ["@cloudflare/workers-types"]
    }
}

M yarn.lock => yarn.lock +10 -0
@@ 2,6 2,11 @@
# yarn lockfile v1


"@cloudflare/workers-types@^3.2.0":
  version "3.2.0"
  resolved "https://registry.yarnpkg.com/@cloudflare/workers-types/-/workers-types-3.2.0.tgz#df300466f5f8a03b205bdd533990017b0538496e"
  integrity sha512-y0+f7QeB5/fMMdU0wSwvBB18yE9kAD2s7Wben8a4uI4f/EJyE+eJrai5QO52Pq8EmWP0vRpKqZh0qU857WhY2A==

"@tootallnate/once@1":
  version "1.1.2"
  resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"


@@ 2116,6 2121,11 @@ type-check@~0.3.2:
  dependencies:
    prelude-ls "~1.1.2"

typescript@^4.5.2:
  version "4.5.2"
  resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998"
  integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw==

ua-parser-js@1.0.2:
  version "1.0.2"
  resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.2.tgz#e2976c34dbfb30b15d2c300b2a53eac87c57a775"