1
- const path = require ( 'path' )
2
1
const express = require ( 'express' )
3
2
const httpProxy = require ( 'express-http-proxy' )
4
- const { legacyCreateProxyMiddleware : createProxyMiddleware } = require ( 'http-proxy-middleware' ) ;
3
+ const {
4
+ legacyCreateProxyMiddleware : createProxyMiddleware ,
5
+ } = require ( 'http-proxy-middleware' )
5
6
const { authJwt } = require ( '../middlewares' )
6
7
const controller = require ( '../controllers/user.controller' )
7
8
const authController = require ( '../controllers/auth.controller' )
@@ -61,15 +62,21 @@ module.exports = function (
61
62
httpProxy ( metabaseServer )
62
63
)
63
64
64
- // reverse proxy for log.io
65
+ // reverse proxy for log.io on Windows
66
+ // for docker it will be used Dozzle
65
67
app . use (
66
68
'/log-io' ,
67
69
[ authJwt . verifyToken ] ,
68
70
function ( req , _ , next ) {
69
71
authController . addXWebAuthUser ( req )
70
72
next ( )
71
73
} ,
72
- httpProxy ( logioServer )
74
+ logioServer . indexOf ( '//dozzle' ) === - 1
75
+ ? httpProxy ( logioServer )
76
+ : createProxyMiddleware ( {
77
+ target : logioServer ,
78
+ changeOrigin : true ,
79
+ } )
73
80
)
74
81
const wsProxy = createProxyMiddleware ( {
75
82
target : logioServer ,
@@ -86,7 +93,7 @@ module.exports = function (
86
93
wsProxy
87
94
)
88
95
app . on ( 'upgrade' , wsProxy . upgrade )
89
- app . use ( '/static' , express . static ( '../log-io/ui/build/static' ) ) ;
96
+ app . use ( '/static' , express . static ( '../log-io/ui/build/static' ) )
90
97
91
98
app . post ( accessPoint , opcApi ) // realtime data API
92
99
@@ -101,15 +108,15 @@ module.exports = function (
101
108
)
102
109
103
110
app . get ( accessPoint + 'test/admin' , [ authJwt . isAdmin ] , controller . adminBoard )
104
-
111
+
105
112
app . use ( '/svg' , [ authJwt . verifyToken ] , express . static ( '../../svg' ) )
106
113
107
114
// production
108
115
app . use ( '/' , express . static ( '../AdminUI/dist' ) )
109
116
app . use ( '/login' , express . static ( '../AdminUI/dist' ) )
110
117
app . use ( '/dashboard' , express . static ( '../AdminUI/dist' ) )
111
118
app . use ( '/admin' , express . static ( '../AdminUI/dist' ) )
112
-
119
+
113
120
// development
114
121
//app.use('/', httpProxy('localhost:3000/'))
115
122
//app.use('/login', httpProxy('localhost:3000/'))
0 commit comments