Caddy must serve files inline on /media and download on /download.

This commit is contained in:
Roland 2026-03-08 09:54:00 -06:00
parent 19a0e7e1c5
commit da8a9bb923
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
3 changed files with 49 additions and 0 deletions

View file

@ -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');
});
});
});
});

View file

@ -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 {

View file

@ -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 {