@abai/proxydeprecated

Web proxy library for rewriting remote websites

Usage no npm install needed!

<script type="module">
  import abaiProxy from 'https://cdn.skypack.dev/@abai/proxy';
</script>

README

@abai/proxy

All data is processed and relayed to the client on the fly without unnecessary buffering, making unblocker one of the fastest web proxies available.

Method

The script uses "pretty" urls which, besides looking pretty, allow links with relative paths to just work without modification. (E.g. <a href="path/to/file2.html"></a>)

In addition to this, links that are relative to the root (E.g. <a href="/path/to/file2.html"></a>) can be handled without modification by checking the referrer and 307 redirecting them to the proper location in the referring site. (Although the proxy does attempt to rewrite these links to avoid the redirect.)

Cookies are proxied by adjusting their path to include the proxy's URL, and a bit of extra work is done to ensure they remain intact when switching protocols or subdomains.

Limitations

Although the proxy works well for standard login forms and even most AJAX content, OAuth login forms and anything that uses postMessage (Google, Facebook, etc.) are not likely to work out of the box. This is not an insurmountable issue, but it's not one that I expect to have fixed in the near term. Patches are welcome, including both a general-purpose fix to go into the main library, and site-specific fixes to go in the examples folder.

Example

const Proxy = require('@abai/proxy');

const express = require('express');
const app = express();

app.use(new Proxy({ prefix: '/proxy/' }));

app.get('/', (req, res) => {
  // ...
});