Last active
May 27, 2019 08:00
-
-
Save rogeriochaves/1f8e5472fd243709ff763e7317c5120e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 server = express(); | |
const request = require('request'); | |
const proxy = require('http-proxy-middleware'); | |
server.set('view engine', 'ejs'); | |
const createProxy = (path, target) => | |
server.use(path, proxy({ target, changeOrigin: true, pathRewrite: {[`^${path}`]: ''} })); | |
createProxy('/header', 'https://microfrontends-header.herokuapp.com/'); | |
createProxy('/products-list', 'https://microfrontends-products-list.herokuapp.com/'); | |
createProxy('/cart', 'https://microfrontends-cart.herokuapp.com/'); | |
server.get('/', (req, res) => res.render('index')); | |
const port = process.env.PORT || 8080; | |
server.listen(port, () => { | |
console.log(`Homepage listening on port ${port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment