Skip to content

Commit

Permalink
[mlx-ui] handle .js in static handler
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
yhwang committed Oct 29, 2021
1 parent 34c3ba3 commit ce23e3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions dashboard/origin-mlx/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const {
SESSION_SECRET = randomBytes(64).toString('hex'),
KUBEFLOW_USERID_HEADER = 'kubeflow-userid',
REACT_APP_DISABLE_LOGIN = 'false',
REACT_APP_RATE_LIMIT = 100,
} = process.env;

const app = express() as Application;
Expand Down Expand Up @@ -66,7 +67,7 @@ app.use(REACT_APP_BASE_PATH, (req, res, next) => {
if (staticIndex !== -1) {
req.url = req.url.substring(staticIndex)
}
else {
else if (!req.url.endsWith('.js')) {
req.url = '/'
}
StaticHandler(staticDir)(req, res, next);
Expand All @@ -89,7 +90,7 @@ if (REACT_APP_BASE_PATH.length !== 0) {

var limiter = new ratelimit({
windowMs: 1*60*1000, // 1 minute
max: 5
max: REACT_APP_RATE_LIMIT
});

app.get('*', limiter, (req, res) => {
Expand Down
10 changes: 7 additions & 3 deletions dashboard/origin-mlx/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ function App() {
const { data, origin } = event;
switch (data.type) {
case 'iframe-connected':
const element = document.getElementById("iframe") as HTMLIFrameElement;
// TODO: get namespace from user info, use fixed value: mlx for now
element.contentWindow.postMessage({type: 'namespace-selected', value: 'mlx'}, origin);
['iframe', 'iframe-run'].forEach((id) => {
const element = document.getElementById(id) as HTMLIFrameElement;
if (element) {
// TODO: get namespace from user info, use fixed value: mlx for now
element.contentWindow.postMessage({type: 'namespace-selected', value: 'mlx'}, origin);
}
})
break;
}
});
Expand Down

0 comments on commit ce23e3f

Please sign in to comment.