Package Exports
- express-reverse-api-proxy
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (express-reverse-api-proxy) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
express-reverse-proxy
Implementation of reverse proxy with Nodejs / Express. Created to handle HTTP verbs and mantain parameters and request headers.
The main objetive is skip CORS in request, useful in secure knowed servers.
Usage
This module require Express in your main implementation. This module returns an Express Router, for your express implementation.
// Typical express declaration...
var RouterAP = require("express-reverse-api-proxy");
// Other Express middlewares and routes...
app.use("/api_proxy_endpoint", RouterAP);
Every request to endpoint REQUIRE this header:
- x-ap-host -> String with URL of destiny
And REQUIRE an middleware conversion to string, same as next:
const express = require("express");
const app = express();
// Other express declarations and middleware
app.use((req, res, next) => {
var data = "";
req.setEncoding("utf8");
req.on("data", (chunk) => {
data += chunk;
});
req.on("end", () => {
req.rawBody = data; // Attaching special property rawBody. Is a string of request.
next();
});
});
This middleware allows data to be passed to the server without unnecesary conversions.
The response is the same response of original service. test it in Postman or other request tester.