# Single-container Caddy config (docs/DECISIONS.md D15). Serves the static SvelteKit build and
# reverse-proxies /api/* to uvicorn on loopback — the same split apps/web/vite.config.ts's dev
# proxy describes, just as Caddy directives instead of Vite's dev-server proxy.
{
	admin off
	# Explicit, not just implied by using a bare port below: this container is never the TLS
	# terminator (docs/PLAN.md "Service topology" — the host's existing reverse proxy is), so
	# Caddy must never attempt to provision a certificate for whatever it's fronted by.
	auto_https off
}

:8080 {
	encode gzip

	log {
		output stdout
	}

	handle /api/* {
		reverse_proxy 127.0.0.1:8000
	}

	# SPA fallback matching apps/web/vite.config.ts's `adapter({ fallback: 'index.html' })`:
	# any path that isn't a real built file resolves to index.html so client-side routing works
	# on a hard refresh / direct link.
	handle {
		root * /srv/web
		try_files {path} /index.html
		file_server
	}
}
