glitch-assets-buffer v1.1.2
Assets.js via Buffer
A fork of assets-lib that uses Buffers instead of redirects to display images at local addresses.
This utility is made for glitch.com projects, and shouldn't be used anywhere else
In a nutshell
The standard Assets.js automatically redirects your web browser to the actual asset URL when it requested the asset for a website/etc However, with assets-buffer, the asset is sent over in the body of the response.
What this means
Navigating to /assets/foobar.png on the old system redirects you to https://cdn.hyperdev.com/us-east-1%3A1a0f89c8-26bf-4073-baed-2b409695e959%2Ffoobar.png Whereas navigating to /assets/foobar.png displays the same image without redirecting you.
Getting Started
Install:
Local) Just copy and paste the contents of assets-buffer.js into your Glitch project. Express is required to be installed for assets-buffer.js to work
NPM) Add this line to your package.json:
{
"dependencies": {
"glitch-assets-buffer": "^1.1.2"
}
}
Example usage:
Then reference that file as follows:
// LOCAL
var assets = require("./assets-buffer.js");
// NPM
var assets = require("glitch-assets-buffer");
var express = require("express");
var app = express();
app.use("/assets", assets);