Hi
I'm experimenting with using D to serve a basic HTML page (using vibe.d), and while the HTML loads fine, none of my image files are rendering in the browser — I only see broken icons.
Here’s the relevant part of my D code that serves the HTML:
import vibe.vibe;
void handleRequest(HTTPServerRequest req, HTTPServerResponse res)
{
res.writeBody(`
void main()
{
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = ["::1", "127.0.0.1"];
listenHTTP(settings, &handleRequest);
runApplication();
}
And my folder structure looks like this:
project/
├── source/
│ └── app.d
├── public/
│ └── images/
│ └── logo.png
├── dub.json
What I tried:
Verified the image exists at public/images/logo.png
Tried both images/logo.png and /images/logo.png in the HTML
Ensured file permissions are readable
The server runs and returns the HTML just fine
Opened the image directly in the browser via http://localhost:8080/images/logo.png → 404
Questions:
Do I need to explicitly configure vibe.d to serve static files from the public folder?
Is there a helper for serving static assets (like serveStaticFiles) that I’m missing?
Is this a routing issue or a path resolution problem?
I’m still pretty new to using D for web servers, so any help would be appreciated!