Skip to content

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

Open
@dantehemerson

Description

@dantehemerson

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:

const mountPath = getMount(app.mountpath);

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions