Skip to content

Commit bbcf7e1

Browse files
authored
[mlx-ui] handle .js in static handler (#252)
don't modify the request url in static handler if it's js file. we need dashboard_lib.bundle.js if mlx servers on / prefix Signed-off-by: Yihong Wang <[email protected]>
1 parent 0359ddf commit bbcf7e1

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

dashboard/origin-mlx/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# base image
2-
FROM node:14
2+
FROM node:14-slim
33

44
# create app directory
55
RUN mkdir -p /workspace

dashboard/origin-mlx/server/server.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const {
2222
SESSION_SECRET = randomBytes(64).toString('hex'),
2323
KUBEFLOW_USERID_HEADER = 'kubeflow-userid',
2424
REACT_APP_DISABLE_LOGIN = 'false',
25+
REACT_APP_RATE_LIMIT = 100,
2526
} = process.env;
2627

2728
const app = express() as Application;
@@ -66,7 +67,7 @@ app.use(REACT_APP_BASE_PATH, (req, res, next) => {
6667
if (staticIndex !== -1) {
6768
req.url = req.url.substring(staticIndex)
6869
}
69-
else {
70+
else if (!req.url.endsWith('.js')) {
7071
req.url = '/'
7172
}
7273
StaticHandler(staticDir)(req, res, next);
@@ -92,7 +93,7 @@ if (REACT_APP_BASE_PATH.length !== 0) {
9293

9394
var limiter = new ratelimit({
9495
windowMs: 1*60*1000, // 1 minute
95-
max: 5
96+
max: REACT_APP_RATE_LIMIT
9697
});
9798

9899
app.get('*', limiter, (req, res) => {

dashboard/origin-mlx/src/App.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ function App() {
6363
const { data, origin } = event;
6464
switch (data.type) {
6565
case 'iframe-connected':
66-
const element = document.getElementById("iframe") as HTMLIFrameElement;
67-
// TODO: get namespace from user info, use fixed value: mlx for now
68-
element.contentWindow.postMessage({type: 'namespace-selected', value: 'mlx'}, origin);
66+
['iframe', 'iframe-run'].forEach((id) => {
67+
const element = document.getElementById(id) as HTMLIFrameElement;
68+
if (element) {
69+
// TODO: get namespace from user info, use fixed value: mlx for now
70+
element.contentWindow.postMessage({type: 'namespace-selected', value: 'mlx'}, origin);
71+
}
72+
})
6973
break;
7074
}
7175
});

0 commit comments

Comments
 (0)