Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy configuration for production environment. #68

Open
turenc opened this issue Feb 9, 2019 · 1 comment
Open

Proxy configuration for production environment. #68

turenc opened this issue Feb 9, 2019 · 1 comment

Comments

@turenc
Copy link

turenc commented Feb 9, 2019

Hi,

Firstly, realy thanks for this amazing work!
It's runing smoothly in the development environment.

There is a only dev environment server proxy and a comment for production purposes in "Webpack.config.js".
https://github.com/me-12/single-spa-portal-example/blob/master/portal/webpack.config.js
// Proxy config for development purposes. In production, you would configure you webserver to do something similar.
proxy: {
"/app1": {
target: "http://localhost:9001",
pathRewrite: {"^/app1" : ""}
},.....................................................

Can you give an idea about how can i configure web server to do something similar?

Or is there another way?

Thanks,
Türenç.

@yzrzya1
Copy link

yzrzya1 commented Feb 11, 2019

This is my try by using node.js with express and http-proxy-middleware dependencies

------ code below ----------

const path = require('path');
const express = require('express');
const proxy = require('http-proxy-middleware');
const app = express();

app.use(express.static(path.join(__dirname, 'release')));

app.use('/app1', proxy({
target: 'http://localhost:9001',
changeOrigin: true,
pathRewrite: {
'^/app1': '/',
}}));

app.use('/app2', proxy({
target: 'http://localhost:9002',
changeOrigin: true,
pathRewrite: {
'^/app2': '/',
}}));

app.use('/app3', proxy({
target: 'http://localhost:9003',
changeOrigin: true,
pathRewrite: {
'^/app3': '/',
}}));

app.use('/app4', proxy({
target: 'http://localhost:9004',
changeOrigin: true,
pathRewrite: {
'^/app4': '/',
}}));

app.use('/app5', proxy({
target: 'http://localhost:9005',
changeOrigin: true,
pathRewrite: {
'^/app5': '/',
}}));

app.listen(9000);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants