Files
outward-scrapper/cmd/outward-web/main.go
Daniel Legt b9d035d71a feat(webui): add cached image proxy with configurable dir
Add disk-backed image proxy support to the web UI and expose it via
`/api/image`. The proxy validates image URLs, fetches remote images with
a timeout, stores image bytes + metadata in a local cache, and serves
cached responses with proper content type and cache headers.

Also add `SCRAPPR_IMAGE_CACHE` (default `.cache/webui-images`) and pass it
through `cmd/outward-web` into `webui.Run`, with startup logging updated
to include the cache location.

This reduces repeated remote fetches and makes image delivery more
reliable for the UI.feat(webui): add cached image proxy with configurable dir

Add disk-backed image proxy support to the web UI and expose it via
`/api/image`. The proxy validates image URLs, fetches remote images with
a timeout, stores image bytes + metadata in a local cache, and serves
cached responses with proper content type and cache headers.

Also add `SCRAPPR_IMAGE_CACHE` (default `.cache/webui-images`) and pass it
through `cmd/outward-web` into `webui.Run`, with startup logging updated
to include the cache location.

This reduces repeated remote fetches and makes image delivery more
reliable for the UI.
2026-03-16 09:56:47 +02:00

28 lines
542 B
Go

package main
import (
"os"
"scrappr/internal/logx"
"scrappr/internal/webui"
)
func main() {
addr := envOrDefault("SCRAPPR_ADDR", ":8080")
dataPath := envOrDefault("SCRAPPR_DATA", "outward_data.json")
imageCacheDir := envOrDefault("SCRAPPR_IMAGE_CACHE", ".cache/webui-images")
if err := webui.Run(addr, dataPath, imageCacheDir); err != nil {
logx.Eventf("error", "fatal: %v", err)
os.Exit(1)
}
}
func envOrDefault(key, fallback string) string {
if value := os.Getenv(key); value != "" {
return value
}
return fallback
}