Yonle / bandwidth-hero-proxy

Fork of bandwidth-hero-proxy with additional fixups.

Home Page:https://bandwidth-hero.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bandwidth Hero Data Compression Service

This data compression service is used by Bandwidth Hero browser extension. It compresses given image to low-res WebP or JPEG image. Optionally it also converts image to greyscale to save even more data.

It downloads original image and transforms it with Sharp on the fly without saving images on disk.

This is NOT an anonymizing proxy — it downloads images on user's behalf, passing cookies and user's IP address through to the origin host.

Fork Notable Changes

  • Cluster support
  • Change on codes, Including how it handle buffers
  • Added animation support (Which is CPU intensive. Disable by setting NO_ANIMATE in env variable)
  • Fixed CORS problems

Deployment Requirement

  • Atleast NodeJS >= 14 is installed.
  • libvips >= 8.14.2 (You should not need to compile libvips from source if sharp could be installed in your machine/container without any problem)

Setting up

Clone the repository, and install required dependencies

git clone https://github.com/Yonle/bandwidth-hero-proxy
npm install

Once finished, Start the server.

node server.js

You may change / set PORT env variable if you want to listen to another port.

If you think your forked cluster is less than 2, You could set CLUSTERS env variable with integer value depending how many clusters you would like to fork.

Using the server

You could also use the server without the need for using bandwidth hero proxy.

The following querystrings parameters is required on request:

  • url: URL of the image (required)
  • jpeg: Whenever to use jpeg format for compression instead of webp (Default: false)
  • bw: Convert the image into grayscale (Default: Yes)
  • l: Image quality (Default: 40% of the original image)

Request URI Example:

https://bwhero.example.com/?url=https%3A%2F%2Fexample.com%2Fbig_image.jpg&bw=0&l=40

Response headers:

  • x-original-size: The original size of the image in bytes
  • x-bytes-saved: How many bytes was saved from the original image

At some point, x-proxy-bypass may appears in header when the server prefers to proxy the non-image content to client.

About

Fork of bandwidth-hero-proxy with additional fixups.

https://bandwidth-hero.com/

License:MIT License


Languages

Language:JavaScript 99.8%Language:Procfile 0.2%