Created
January 17, 2019 14:26
-
-
Save tomlarkworthy/58397046fc28776d1cef7c3c8d88706b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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