-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When panel is enabled, only /index.html
can be directly visited
#192
Comments
I reproduced the problem, except I don't know what it is now. But it looks like the odds are that the front-end file isn't receiving the route forwarding. Because I tried to change the path to It only works if you visit |
I tried to fix this bug and was able to access I mainly utilized the fact that the pages I couldn't find were using the front end to forward requests. I'm not sure if this is the desired result, can you help me out? /// Find the static assets of the administration panel
#[actix_web::get("/_panel{_:.*}")]
pub async fn handle_static_panel(path: web::Path<String>) -> impl Responder {
let path = if path.is_empty() {
"index.html"
} else {
path.as_str().strip_prefix('/').unwrap()
};
let (content_type, content_data) = Asset::get(path)
.map(|content| {
(
from_path(path).first_or_octet_stream().to_string(),
content.data.into_owned(),
)
})
.unwrap_or_else(|| {
let default_content = Asset::get("index.html").unwrap();
(
"text/html; charset=utf-8".to_string(),
default_content.data.into_owned(),
)
});
HttpResponse::Ok()
.content_type(content_type)
.body(content_data)
} |
Hello @dierbei, Thank you for taking the issue and submit the PR to fix it! 👏
Yes, this is the expected result. The administration panel is a Single Page Application (SPA), so the routing happens in the browser. If you access the panel on The solution you proposed fix this error by returning the
This is the reason why you were getting these errors. The server didn't find any Thank you!! |
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 underclient/dist
when building.The logic that handles this is at:
wasm-workers-server/crates/panel/src/handlers/panel.rs
Lines 18 to 29 in 549387b
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:
index.html
, as per the current logic.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
The text was updated successfully, but these errors were encountered: