Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include dependencies
- const express = require('express');
- const { createProxyMiddleware } = require('http-proxy-middleware');
- // proxy middleware options
- const options = {
- target: 'https://www.famousfootwear.com', // target host
- changeOrigin: true, // needed for virtual hosted sites
- ws: true, // proxy websockets
- router: {
- // when request.headers.host == 'dev.localhost:3000',
- // override target 'http://www.example.org' to 'http://localhost:8000'
- 'dev.localhost:3000': 'http://localhost:8000',
- },
- autoRewrite: true,
- };
- // create the proxy (without context)
- const exampleProxy = createProxyMiddleware(options);
- // mount `exampleProxy` in web server
- const app = express();
- app.use('*', exampleProxy);
- app.listen(3000);
Add Comment
Please, Sign In to add comment