Public
Script
1
2
3
4
5
6
import { insecureFetch } from "https://esm.town/v/stevekrouse/insecureFetch";
const url = "https://assignment-api.uspto.gov/patent/basicSearch?query=1234567&fields=main&rows=20";
const data = await insecureFetch(url);
const text = await data.text();
console.log(text);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
April 10, 2024
Cloudflare workers doesn't validate https certs???
Apparently not!
I assume it supports only GET requests?
I think it's a pretty naive proxy that supports anything, why do you ask, @vladimyr?
I didn't have any particular use case in mind just curious to know what to write next to it in my notes :)
And to answer my question, no POST requests aren't supported:
Also, keep in mind that you need to URL encode
url
param:In @stevekrouse's example:
https://unsecure-fetch.val-town.workers.dev?url=https://assignment-api.uspto.gov/patent/basicSearch?query=1234567&fields=main&rows=20
query
is consumed by proxied URL butfields
androws
get consumed by proxy instead ⚠️It should now support POST requests and everything else – it forwards the whole req with the url changed.
I also made a helper method: @stevekrouse/insecureFetch
And include the source on the fetch's homepage: https://unsecure-fetch.val-town.workers.dev/
Oh, this is great! ❤️
I couldn't resist so I forked it and made it conform to the standard
fetch
signature allowing to easily switch between platform native, @std/fetch and @stevekrouse/insecureFetch as seen here: https://www.val.town/v/vladimyr/fetch_impl_examplesOn a seemingly related note, the way you served source code reminded me of https://ghuc.cc/worker-tools/ghuc.cc/index.js