The headers are set in the .htaccess file that ships with Nextcloud. If you’re using a different web server such as Nginx, you would need to set the headers in the web server configuration.
This is a known issue. See Notification about an "upgrade" to ownCloud 9.1.1 in Nextcloud 10 stable