Skip to content

Commit

Permalink
Add proxy configuration to enable communication for all microfrontends.
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan-tonchev committed Jul 8, 2024
1 parent 34a7696 commit e77f23e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ NAVBAR_PROTOCOL = 'http'
NAVBAR_HOST = 'localhost'
NAVBAR_PORT = 9006

API_PREFIX = '/api'
API_PROTOCOL = 'http'
API_HOST = 'localhost'
API_PORT=9003

GRAPH_DB_PROTOCOL='http'
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@ontotext/workbench-api",
"scripts": {
"start": "webpack serve --port",
"start": "webpack serve",
"start:standalone": "webpack serve --env standalone",
"build": "concurrently npm:build:*",
"build:webpack": "webpack --mode=production",
Expand Down
1 change: 1 addition & 0 deletions packages/api/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const {merge} = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa-ts");
require('dotenv').config({path:'../../.env'});

module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
Expand Down
3 changes: 2 additions & 1 deletion packages/legacy-workbench/webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const MergeIntoSingleFilePlugin = require('webpack-merge-and-include-globally');
const WebpackAutoInject = require('webpack-auto-inject-version');
require('dotenv').config({path:'../../.env'});

// Pass this function as a transform argument to CopyPlugin elements to replace [AIV]{version}[/AIV]
// with the current workbench version number. This is not related to the WebpackAutoInject plugin
Expand All @@ -24,7 +25,7 @@ module.exports = {
path: path.resolve(__dirname, 'dist'),
libraryTarget: "system",
// TODO MAKE IT BY CONFIGURATION
publicPath: "http://localhost:9001/",
publicPath: process.env.LEGACY_WORKBENCH_PROTOCOL + '://' + process.env.LEGACY_WORKBENCH_HOST + ':' + process.env.LEGACY_WORKBENCH_PORT + "/",
},
resolve: {
modules: [
Expand Down
2 changes: 1 addition & 1 deletion packages/root-config/src/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
"imports": {
"single-spa": "https://cdn.jsdelivr.net/npm/[email protected]/lib/system/single-spa.min.js",
"@ontotext/workbench-api": "http://localhost:9003/ontotext-workbench-api.js"
"@ontotext/workbench-api": "/api/ontotext-workbench-api.js"
}
}
</script>
Expand Down
6 changes: 6 additions & 0 deletions packages/root-config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { merge } = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const path = require("path");
require('dotenv').config({path:'../../.env'});

require('dotenv').config({path:'../../.env'});

Expand Down Expand Up @@ -66,6 +67,11 @@ module.exports = (webpackConfigEnv, argv) => {
target: process.env.NAVBAR_PROTOCOL + '://' + process.env.NAVBAR_HOST + ':' + process.env.NAVBAR_PORT,
pathRewrite: { [`^${process.env.NAVBAR_PREFIX}`]: '' }
},
{
context: [process.env.API_PREFIX],
target: process.env.API_PROTOCOL + '://' + process.env.API_HOST + ':' + process.env.API_PORT,
pathRewrite: { [`^${process.env.API_PREFIX}`]: '' }
},
{
context: ['/rest', '/repositories', '/protocol', '/rdf-bridge'],
target: process.env.LEGACY_WORKBENCH_PROTOCOL + '://' + process.env.LEGACY_WORKBENCH_HOST + ':' + process.env.LEGACY_WORKBENCH_PORT,
Expand Down

0 comments on commit e77f23e

Please sign in to comment.