You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried serve_dir both with the absolute path (above) or (preferably) with a relative one. In both cases it doesn't work as expected (I expect / to serve /static/index.html and /favicon.jpg to resolve the same way).
I would instead get something like this:
2023-05-01T04:52:48.658475Z INFO tide::log::middleware: <-- Request received
2023-05-01T04:52:48.658572Z INFO Request{http.method=GET http.target=/}: tide_tracing: received
2023-05-01T04:52:48.658649Z WARN Request{http.method=GET http.target=/}:Response{http.status_code=404 http.duration=41.377µs}:Client error: tide_tracing: sent
2023-05-01T04:52:48.658699Z WARN tide::log::middleware: Client error --> Response sent
Whatever I try, tide just returns a 404 - which doesn't make sense to me at all. Worse though: While experimenting and trying to figure out what's going on, I stumbled upon this: Requesting /static/index.html causes a panic and a 500 handling the request, which is arguably worse than the confusing 404:
2023-05-01T04:53:02.376075Z INFO tide::log::middleware: <-- Request received
2023-05-01T04:53:02.376098Z INFO Request{http.method=GET http.target=/static/index.html}: tide_tracing: received
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', /home/bam/.cargo/registry/src/github.com-1ecc6299db9ec823/tide-0.16.0/src/fs/serve_dir.rs:28:52
The text was updated successfully, but these errors were encountered:
I'm having the same issue. At first I was getting 404 errors, but after changing the serve directory from ./static/ to ./src/static/, now I'm getting the same panics as @darklajid.
After pulling down my own copy of tide and looking through the code, I think it may have to do with the usage of strip_prefix within the ServeDir's call function. It's an "unstable" feature atm and so I think it's returning None during "stable" usage.
A quick work-around for those that are having this issue:
Fork the repo
Replace your dependency to be tide = { git = "https://github.com/[your repo name]/tide" }
strip_prefix for me seems to be trying to strip the wildcard (*) from the path as well. It was possible for me to circumvent this issue by doing app.at("/").serve_dir("my_dir") instead of app.at("/*").serve_dir("my_dir"). I think the examples in the default branch are not correct for tide 0.16.0?
A tiny sample project. I have
where main.rs is roughly this:
I tried
serve_dir
both with the absolute path (above) or (preferably) with a relative one. In both cases it doesn't work as expected (I expect/
to serve/static/index.html
and/favicon.jpg
to resolve the same way).I would instead get something like this:
Whatever I try, tide just returns a 404 - which doesn't make sense to me at all. Worse though: While experimenting and trying to figure out what's going on, I stumbled upon this: Requesting
/static/index.html
causes a panic and a 500 handling the request, which is arguably worse than the confusing 404:The text was updated successfully, but these errors were encountered: