Skip to content

Add custom HTML 404 page #24

Description

@bonheur15

Problem

The default 404 handler is Go's built-in http.NotFound(), which returns a plain text "404 page not found" response for unrecognized paths on the CDN node.

Location: internal/server/server.go:334

Current Code

http.NotFound(w, r)

Proposed Fix

Create a simple HTML 404 page consistent with the existing design language (using the same layout template or a standalone page):

func render404(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Content-Type", "text/html; charset=utf-8")
    w.WriteHeader(http.StatusNotFound)
    // Render a simple 404 page using templ or inline HTML
}

Or add a templ component:

templ notFound() {
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>404 - Not Found</title>
    </head>
    <body>
        <main>
            <h1>404</h1>
            <p>This path doesn't exist on this node.</p>
            <p><a href="/">Back to hubCDN</a></p>
        </main>
    </body>
    </html>
}

Why This Matters

A plain text 404 is jarring and unprofessional. A styled 404 page maintains brand consistency and can guide users back to the landing page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions