diff options
| author | akiyamn | 2023-09-24 23:22:21 +1000 |
|---|---|---|
| committer | akiyamn | 2023-09-24 23:22:21 +1000 |
| commit | 4e87195739f2a5d9a05451b48773c8afdc680765 (patch) | |
| tree | 9cba501844a4a11dcbdffc4050ed8189561c55ed /node_modules/wrangler/templates/checked-fetch.js | |
| download | price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.tar.gz price-tracker-worker-4e87195739f2a5d9a05451b48773c8afdc680765.zip | |
Initial commit (by create-cloudflare CLI)
Diffstat (limited to 'node_modules/wrangler/templates/checked-fetch.js')
| -rw-r--r-- | node_modules/wrangler/templates/checked-fetch.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/wrangler/templates/checked-fetch.js b/node_modules/wrangler/templates/checked-fetch.js new file mode 100644 index 0000000..cf630c0 --- /dev/null +++ b/node_modules/wrangler/templates/checked-fetch.js @@ -0,0 +1,30 @@ +const urls = new Set(); + +function checkURL(request, init) { + const url = + request instanceof URL + ? request + : new URL( + (typeof request === "string" + ? new Request(request, init) + : request + ).url + ); + if (url.port && url.port !== "443" && url.protocol === "https:") { + if (!urls.has(url.toString())) { + urls.add(url.toString()); + console.warn( + `WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:\n` + + ` - ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.\n` + ); + } + } +} + +globalThis.fetch = new Proxy(globalThis.fetch, { + apply(target, thisArg, argArray) { + const [request, init] = argArray; + checkURL(request, init); + return Reflect.apply(target, thisArg, argArray); + }, +}); |
