{
	admin off
	log default {
		output discard
	}
}

www.housecall.chat {
	redir https://housecall.chat{uri} permanent
}

housecall.chat {
	encode zstd gzip
	header {
		Strict-Transport-Security "max-age=31536000"
		X-Content-Type-Options nosniff
		X-Frame-Options DENY
		Referrer-Policy no-referrer
		Permissions-Policy "camera=(), microphone=(), geolocation=()"
		-Server
	}
	@portal path /app /app/* /api/account /api/account/*
	header @portal {
		Cache-Control no-store
		Content-Security-Policy "default-src 'none'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self'; font-src 'self'; connect-src 'self'; img-src 'self'; base-uri 'none'; frame-ancestors 'none'; form-action 'none'; object-src 'none'"
	}
	@landing not path /app /app/* /api/account /api/account/*
	header @landing {
		Cache-Control no-cache
		Content-Security-Policy "default-src 'none'; style-src 'self'; font-src 'self'; img-src 'self' data:; base-uri 'none'; frame-ancestors 'none'; form-action 'none'; object-src 'none'"
	}
	handle /api/account* {
		request_body {
			max_size 96KB
		}
		reverse_proxy 127.0.0.1:43180 {
			header_up X-Forwarded-For {remote_host}
			transport http {
				dial_timeout 2s
				response_header_timeout 12s
			}
		}
	}
	handle /app {
		redir /app/ 308
	}
	handle_path /app/* {
		root * /srv/housecall/current/portal/dist
		file_server
	}
	handle_path /source/* {
		root * /srv/housecall/current/source
		file_server
	}
	handle {
		@privacy path /privacy /privacy/
		rewrite @privacy /privacy.html
		root * /srv/housecall/current/website
		file_server
	}
}

:80 {
	respond "HouseCall setup in progress. Use https://housecall.chat once setup is complete." 503
}
