parse-community / parse-community/parse-dashboard

Error loading resources when parse-dashboard in mounted on a subpath

Open
#1,747 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:bug
Dominant language
JavaScript
Stars
3.8k
Forks
1.4k
PR merge metrics
No merged PRs in 30d

Description

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Dashboard!

  • You're running version >=1.0.23 of Parse Dashboard.

  • You're running version >=2.3.2 of Parse Server.

  • You've searched through existing issues. Chances are that your issue has been reported or resolved before.

Environment Setup
Issue

I'm using the parse-dashboard as express-middleware, and I'm mounting on /dashboard route:

dashboardApp.use('/dashboard', dashboard);

My API is being mounted on a subpath in my organization, e.g. https://my.org/sub/path, which means the Dashboard would be accessible at https://my.org/sub/path/dashboard.

But in the app, the path taken by parse-dashboard is /dashboard, which leads to incorrect resources paths in the HTML.

I have created an example here simulating the problem.

screenshot (1)

Console logs:

image

As you can see, it loads the resources from the base path.

The expected behavior should be to load the resources with /sub/path/dashboard prefix.

Steps to reproduce

Mount express app in a subpath.

const dashboardApp = express();
// ParseDashboard takes '/dashboard' as mountpath
dashboardApp.use('/dashboard', dashboard);

// Mount dashboard at /sub/path/dashboard
app.use('/sub/path/', dashboardApp);


const httpServer = require('http').createServer(app);
httpServer.listen(port);

You can see the complete example simulating the problem here.

My simple solution

In this part of the code:

https://github.com/parse-community/parse-dashboard/blob/92fe6a5a934810b4d9d28b9c18f96c7ea73645dd/Parse-Dashboard/app.js#L62

I have added an option in the middleware to support a prefix param.

const mountPath = (options.prefix || '' ) + getMount(app.mountpath);

and it can be used as:

dashboardApp.use('/dashboard',  new ParseDashboard(..., { prefix: `/sub/path`  }));

I want to know what are your regardings about it.

If you think this feature can be added, I could take it.

Logs/Trace

Note: If you get a browser JS error please run npm run dev. This will provide source maps and a much more useful stack trace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the mounted-subpath case using the example app.js around lines 34–39, then inspect Parse-Dashboard/app.js around line 62 to trace how the mount path is assembled. Done means dashboard resources load from the full /sub/path/dashboard prefix when Parse Dashboard is mounted through Express middleware.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, javascript
Domain
backend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.