From da8a9bb92316e9ca55df752f17c3c34a7515cf04 Mon Sep 17 00:00:00 2001 From: Roland Date: Sun, 8 Mar 2026 09:54:00 -0600 Subject: [PATCH] Caddy must serve files inline on /media and download on /download. --- app/cypress/e2e/caddy-media.cy.js | 27 +++++++++++++++++++++++++++ docker/web/Caddyfile | 11 +++++++++++ etc/raspberrypios/Caddyfile | 11 +++++++++++ 3 files changed, 49 insertions(+) create mode 100644 app/cypress/e2e/caddy-media.cy.js diff --git a/app/cypress/e2e/caddy-media.cy.js b/app/cypress/e2e/caddy-media.cy.js new file mode 100644 index 00000000..0b48e586 --- /dev/null +++ b/app/cypress/e2e/caddy-media.cy.js @@ -0,0 +1,27 @@ +describe('Caddy Media Serving Tests', () => { + + describe('/media/ Content-Disposition inline', () => { + it('sets Content-Disposition inline on /media/ file requests', () => { + cy.request('GET', '/media/config/wrolpi.yaml').then((response) => { + expect(response.status).to.eq(200); + expect(response.headers['content-disposition']).to.contain('inline'); + }); + }); + + it('serves .yaml files with text/yaml Content-Type', () => { + cy.request('GET', '/media/config/wrolpi.yaml').then((response) => { + expect(response.status).to.eq(200); + expect(response.headers['content-type']).to.contain('text/yaml'); + }); + }); + }); + + describe('/download/ Content-Disposition attachment', () => { + it('sets Content-Disposition attachment on /download/ file requests', () => { + cy.request('GET', '/download/config/wrolpi.yaml').then((response) => { + expect(response.status).to.eq(200); + expect(response.headers['content-disposition']).to.contain('attachment'); + }); + }); + }); +}); diff --git a/docker/web/Caddyfile b/docker/web/Caddyfile index aa31d732..815f037b 100644 --- a/docker/web/Caddyfile +++ b/docker/web/Caddyfile @@ -67,9 +67,20 @@ redir * /docs/ 301 } + # Custom MIME types not in Caddy's defaults. + @yaml path *.yaml *.yml + header @yaml Content-Type "text/yaml" + + @epub path *.epub + header @epub Content-Type "application/epub+zip" + + @mobi path *.mobi + header @mobi Content-Type "application/x-mobipocket-ebook" + # Static media files with directory browsing. handle_path /media/* { root * /opt/media + header Content-Disposition "inline" file_server browse } handle /media { diff --git a/etc/raspberrypios/Caddyfile b/etc/raspberrypios/Caddyfile index c9353046..0fe81572 100644 --- a/etc/raspberrypios/Caddyfile +++ b/etc/raspberrypios/Caddyfile @@ -67,9 +67,20 @@ redir * /docs/ 301 } + # Custom MIME types not in Caddy's defaults. + @yaml path *.yaml *.yml + header @yaml Content-Type "text/yaml" + + @epub path *.epub + header @epub Content-Type "application/epub+zip" + + @mobi path *.mobi + header @mobi Content-Type "application/x-mobipocket-ebook" + # Static media files with directory browsing. handle_path /media/* { root * /media/wrolpi + header Content-Disposition "inline" file_server browse } handle /media {