ITADN

Relative paths are not served well

#95Closeddoronbehar 创建于 2024-08-04
D
doronbeharcommented
MWE of an HTML/CSS website layout: ``` $ tree . . ├── html └── my └── page ├── index.css └── index.html 3 directories, 3 files ``` ### `my/page/index.css` ```css body { direction:rtl; } ``` ### `my/page/index.html` ```html <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> <link rel="stylesheet" type="text/css" href="index.css"/> <title>-</title> </head> <body> Hello world </body> </html> ``` Logs: ``` [2024-08-04T15:31:42Z WARN live_server::server] Failed to read "/home/doron/repos/live-server-relative-paths-issue-example/index.html": No such file or directory (os error 2) [2024-08-04T15:31:42Z WARN live_server::server] Failed to read "/home/doron/repos/live-server-relative-paths-issue-example/favicon.ico": No such file or directory (os error 2) [2024-08-04T15:31:47Z WARN live_server::server] Failed to read "/home/doron/repos/live-server-relative-paths-issue-example/my/index.css": No such file or directory (os error 2) ``` Whereas if I open the same `index.html` file directly in the browser, the css file is loaded correctly - as can be seen by the `body` direction. When working on [my website](https://gitlab.com/doronbehar/doronbehar.gitlab.io), which has multiple `index.css` files, this bug was very confusing to me.
关闭于 2024-08-10 9 条评论