{
    debug
}

:80 {
	respond /caddy-health-check 200

	handle_path /media/* {
		@downloads {
			query dl=*
		}
		header @downloads Content-disposition "attachment; filename={query.dl}"

	    header {
    		Access-Control-Allow-Origin {$PUBLIC_WEB_FRONTEND_URL:http://localhost:3000}
    		Access-Control-Allow-Methods "GET, HEAD, OPTIONS"
    		Access-Control-Allow-Headers "*"
    		Access-Control-Expose-Headers "Content-Length, Content-Type"
    	}

		file_server {
			root {$MEDIA_ROOT:/baserow/media/}
		}
	}
}