Rob's garden / notes / Custom HTTP proxy for ESM code

Custom HTTP proxy for ESM code

Playing around with a little HTTP proxy that renders the proxied code as HTML if you send that Accept header or just proxies the request otherwise.

The idea is to have ESM code in an S3-like bucket then run this in-front of it so I can access the code for Deno-like imports or view it in a browser to see stack errors.

I have a prototype running on my #Homelab too! An example:

It was a good excuse to play around with CodeMirror too ~ https://codemirror.net/

When rendering as HTML, I ended up fetching the source code and putting it into a <template> tag that it can read and render client-side. I couldn't work out a simple way to store it un-html-encoded in the document though so it gets a bit messed up

Update: I've since turned this off. It was a cool experiment.