Readme

This is an example call of @stevekrouse/insecureFetch

Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
10
easrng avatar

Cloudflare workers doesn't validate https certs???

stevekrouse avatar

Apparently not!

vladimyr avatar

I assume it supports only GET requests?

stevekrouse avatar

I think it's a pretty naive proxy that supports anything, why do you ask, @vladimyr?

vladimyr avatar

I didn't have any particular use case in mind just curious to know what to write next to it in my notes :)

vladimyr avatar

And to answer my question, no POST requests aren't supported:

$ curl -s 'https://pie.dev/post' -F'foo=bar' # works $ curl -s 'https://unsecure-fetch.val-town.workers.dev?url=https://pie.dev/post' -F'foo=bar' # returns 405 Method Not Allowed
vladimyr avatar

Also, keep in mind that you need to URL encode url param:

$ curl -s 'https://unsecure-fetch.val-town.workers.dev?url=https://pie.dev/get?foo=bar&baz=42' | jq -c '.args' # ==> {"foo":"bar"} $ curl -s 'https://unsecure-fetch.val-town.workers.dev?url=https%3A%2F%2Fpie.dev%2Fget%3Ffoo%3Dbar%26baz%3D42' | jq -c '.args' # ==> {"baz":"42","foo":"bar"}

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 but fieldsand rows get consumed by proxy instead ⚠️

stevekrouse avatar

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/

vladimyr avatar

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_examples

vladimyr avatar

On a seemingly related note, the way you served source code reminded me of https://ghuc.cc/worker-tools/ghuc.cc/index.js

April 10, 2024