Created
February 26, 2019 07:28
-
-
Save beacrea/0fe1e9d6d57400f18f21ba6109bc86b0 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
/* SERVER ONE */ | |
const express = require('express') | |
const cors = require('cors') | |
const proxy = require('express-http-proxy') | |
const app = express() | |
// Table Options | |
// CORS and JSON Config | |
app.use(cors()) | |
app.set('json spaces', 40) | |
// Route handler | |
app.get('/', function(req, res) { | |
res.send('Yo! This is the backend server of Coty Beasley. (https://coty.design)') | |
}) | |
app.use('/hey', proxy('localhost:9098', { | |
forwardPath: function (req, res) { | |
return req.url | |
} | |
})) | |
// Port listener | |
app.listen(3010, () => console.log('Example app listening on port 9098!')) | |
module.exports = app | |
/* SERVER TWO */ | |
const express = require('express') | |
const cors = require('cors') | |
const proxy = require('http-proxy-middleware') | |
const app = express() | |
const path = require('path') | |
// Table Options | |
// CORS and JSON Config | |
app.use(cors()) | |
app.set('json spaces', 40) | |
// Route handler | |
// Catchall | |
app.get('/', function (req, res) { | |
res.sendFile(path.join(__dirname + '/index.html')); | |
}); | |
// Port listener | |
app.listen(9098, () => console.log('Example app listening on port 9098!')) | |
module.exports = app |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment