Use CI4 to set headers: https://codeigniter4.github.io/userguide/outgoing/response.html#setting-headers
I added the following to the controller and that fixed it!
$this->response->setHeader('Content-Type', 'text/xml');