Skip to content

Instantly share code, notes, and snippets.

View sephi-dev's full-sized avatar
🎯
Focusing

David sephi-dev

🎯
Focusing
View GitHub Profile
@sephi-dev
sephi-dev / api.proxy.server.js
Created July 1, 2018 19:39 — forked from davemo/api.proxy.server.js
A simple express.js server with a proxy that intercepts all requests with /api/ and proxies them to localhost:3000
var express = require('express'),
httpProxy = require('http-proxy'),
app = express();
var proxy = new httpProxy.RoutingProxy();
function apiProxy(host, port) {
return function(req, res, next) {
if(req.url.match(new RegExp('^\/api\/'))) {
proxy.proxyRequest(req, res, {host: host, port: port});