Skip to content

Instantly share code, notes, and snippets.

@korrio
Forked from rogeriochaves/server.js
Created May 27, 2019 08:00
Show Gist options
  • Save korrio/05d49e70c174da5cd18749cc6adc295c to your computer and use it in GitHub Desktop.
Save korrio/05d49e70c174da5cd18749cc6adc295c to your computer and use it in GitHub Desktop.
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