Skip to content

When panel is enabled, only /index.html can be directly visited #192

Closed
@ereslibre

Description

@ereslibre

Describe the bug

When the panel is enabled --enable-panel, the logic that handles the panel endpoints will only serve /index.html and any assets that are discovered under client/dist when building.

The logic that handles this is at:

let path = if path.len() == 0 {
"index.html"
} else {
path.as_str().strip_prefix('/').unwrap()
};
match Asset::get(path) {
Some(content) => HttpResponse::Ok()
.content_type(from_path(path).first_or_octet_stream().as_ref())
.body(content.data.into_owned()),
None => HttpResponse::NotFound().body("404 Not Found"),
}

There are other virtual paths such as /_panel/workers that are not covered by any of this cases.

Ideally, to avoid duplicating routing in multiple places, this logic should:

  1. If path is empty, default to index.html, as per the current logic.
  2. If an asset exists, serve it, as per the current logic.
  3. Otherwise, serve a static page, that will perform an AJAX request to the current path and will forward the response to the client.

This way, we keep the current Single Page Application (SPA) approach, while making arbitrary paths directly visitable (e.g. reload endpoint, write path in location bar and hit enter...)

Reproduction steps

Run wws with --enable-panel. Visit /_panel/workers. The server will return a 404 HTTP status code.

Expected behavior

Visiting /_panel/workers directly should be equivalent to visiting / and navigating through the UI to the list of workers.

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions