Skip to content

Commit f6de589

Browse files
committed
fix: 修复 ServeDir 的 not_found_service 方法调用
ServeDir 的 not_found_service 方法已更改为 fallback 方法,以正确处理找不到的文件时的回退服务。这将确保在用户请求的文件不存在时,会返回默认的 index.html 文件。
1 parent 45f772d commit f6de589

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
147147

148148
// Serve SPA static files from web/dist/ with fallback to index.html
149149
let spa = ServeDir::new("web/dist")
150-
.not_found_service(ServeFile::new("web/dist/index.html"));
150+
.fallback(ServeFile::new("web/dist/index.html"));
151151
app = app.fallback_service(spa);
152152

153153
// Start server

0 commit comments

Comments
 (0)