Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const express = require('express');
const proxy = require('http-proxy-middleware')
const request = require('request');
const build = "20181223"
const domain = "us-central1-corepox-staging.cloudfunctions.net"
const wordpress = 'https://corepoxblog.com';
const app = express();
app.get('/universe/ships/:shipId', async (req, res) => {
var backend = `https://${domain}/shipsnapshot?build=${build}&shipId=${req.params.shipId}`;
request(backend).pipe(res);
});
app.get('/universe/leaderboards/ships', async (req, res) => {
var backend = `https://${domain}/shipLeaderboard`;
request(backend).pipe(res);
});
// Our final catchall is to wordpress, so in addition to blog posts, 404's etc. are also
// customized within wordpress
app.use('*', proxy({
target: wordpress,
changeOrigin: true // Needed for vitual hosts
}));
module.exports = {
proxy: app
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment