{
	# 如需关闭管理接口，可取消下一行注释 / Uncomment to disable admin API
	# admin off
}

(app_routes) {
	encode gzip zstd

	# /api-debug 是前端 SPA 路由，不要代理到后端
	handle /api-debug* {
		root * /usr/share/caddy
		try_files {path} {path}/ /index.html
		file_server
	}

	# API 请求反向代理到后端服务 / Proxy API requests to backend
	handle /api* {
		reverse_proxy backend:8080
	}

	# 上传的凭证图片等静态资源 / Proxy uploads to backend
	handle /uploads* {
		reverse_proxy backend:8080
	}

	# 前端 SPA 静态文件 / Serve frontend SPA
	handle {
		root * /usr/share/caddy
		try_files {path} {path}/ /index.html
		file_server
	}
}

:80 {
	import app_routes
}

skin.khhao.com {
	import app_routes
}
