1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-30 22:50:10 +03:00

B #3951: fix routing server fireedge (#358)

Signed-off-by: Jorge Lobo <jlobo@opennebula.io>

Co-authored-by: Jorge Lobo <jlobo@opennebula.systems>
This commit is contained in:
Jorge Miguel Lobo Escalona 2020-10-26 10:53:11 +01:00 committed by GitHub
parent a0c3aa981b
commit e39644629a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 9 deletions

View File

@ -15,7 +15,7 @@ import {
} from 'fs-extra'
import http from 'http'
import https from 'https'
import { defaultTypeLog, defaultPort, defaultWebpackMode } from './utils/constants/defaults'
import { defaultTypeLog, defaultPort, defaultWebpackMode, defaultApps } from './utils/constants/defaults'
import {
validateServerIsSecure,
getCert,
@ -109,9 +109,12 @@ app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
app.use('/api', entrypointApi) // opennebula Api routes
app.get('/provision', entrypointApp)
app.get('/fireedge', entrypointApp)
app.get('/', (req, res) => res.send('index'))
const frontApps = Object.keys(defaultApps)
frontApps.map(frontApp => {
app.get(`/${frontApp}`, entrypointApp)
app.get(`/${frontApp}/*`, entrypointApp)
})
app.get('/*', (req, res) => res.send('index'))
// 404 - public
app.get('*', entrypoint404)

View File

@ -33,7 +33,7 @@ router.get('*', (req, res) => {
let storeRender = ''
let chunks = ''
if (env.NODE_ENV === 'production') {
app = req.url.replace(/\//g, '')
app = req.url.split(/\//gi).filter(sub => sub && sub.length > 0)[0]
chunks = `<script src='/client/1.bundle.${app}.js'></script>`
}

View File

@ -13,10 +13,17 @@
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
const apps = {
fireedge: {
assets: true
},
provision: undefined
}
const default2FAOpennebulaVar = 'TWO_FACTOR_AUTH_SECRET'
const defaultIp = '127.0.0.1'
const protocol = 'http'
const defaults = {
defaultApps: apps,
httpMethod: {
GET: 'GET',
POST: 'POST',

View File

@ -8,7 +8,8 @@ const js = {
include: path.resolve(__dirname, 'src', 'client')
}
const bundle = ({ name = 'fireedge' } = {}) => {
const bundle = () => {
const devPathFile = path.resolve(__dirname, 'src', 'client', 'dev.js')
const plugins = [
new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
@ -21,11 +22,11 @@ const bundle = ({ name = 'fireedge' } = {}) => {
mode: defaultWebpackMode,
entry: [
'webpack-hot-middleware/client',
path.resolve(__dirname, 'src', 'client', 'dev.js')
devPathFile
],
target: 'web',
output: {
path: path.resolve(__dirname, 'src', 'client', 'dev.js'),
path: devPathFile,
filename: 'bundle.dev.js',
publicPath: '/client'
},

View File

@ -1,6 +1,7 @@
const path = require('path')
const webpack = require('webpack')
const CopyPlugin = require('copy-webpack-plugin')
const { defaultApps } = require('./src/server/utils/constants/defaults')
const js = {
test: /\.js$/,
@ -41,4 +42,6 @@ const bundle = ({ assets = false, name = 'fireedge' }) => {
}
}
module.exports = [bundle({ assets: true }), bundle({ name: 'provision' })]
module.exports = () => Object.entries(defaultApps).map(([key, values]) =>
bundle({ ...values, name: key })
)