# One site for the game (decision 0.5.20): the API under /api, the app for
# everything else. SITE_ADDRESS is the public domain (HTTPS via Let's Encrypt),
# or ":80" for plain HTTP when testing.
{$SITE_ADDRESS} {
	encode zstd gzip

	handle /api/* {
		reverse_proxy server:3000
	}

	handle {
		root * /srv
		# Client-side routes (/fleet, /contracts…) all load the app.
		try_files {path} /index.html
		file_server
	}

	# Vite's hashed bundles and fonts never change under the same name.
	@hashed path_regexp hashed ^/assets/[^/]+-[A-Za-z0-9_-]{8}\.(js|css|woff2?)$
	header @hashed Cache-Control "public, max-age=31536000, immutable"

	# The shell and service worker must always be checked for a new version.
	@shell path / /index.html /sw.js /registerSW.js /manifest.webmanifest
	header @shell Cache-Control "no-cache"
}
