-
-
Save korrio/05d49e70c174da5cd18749cc6adc295c 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 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