You are looking for nextcloud-raw :
Raw — Nextcloud raw file server
Raw simply returns any requested file, so you can link directly to a file itself (i.e. without any of NextCloud’s interface around it). This enables you to host static web pages, images or other files, for example to link/embed them elsewhere on the web.
For security and privacy, the content is served with a Content-Security-Policy header. This header instructs browsers to not load any remote content, nor execute any scripts that it may contain (of course, the downside is that your web pages cannot use javascript for interactivity).
It works for images out of the box and for videos you have to remove two content security headers (“default-src ‘none’:;” and “media-src data:;”)
Use at your own risk (I do )