Skip to content

Instantly share code, notes, and snippets.

@tomlarkworthy
Created January 17, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlarkworthy/58397046fc28776d1cef7c3c8d88706b to your computer and use it in GitHub Desktop.
Save tomlarkworthy/58397046fc28776d1cef7c3c8d88706b to your computer and use it in GitHub Desktop.
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