mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Caddy must serve files inline on /media and download on /download.
This commit is contained in:
parent
19a0e7e1c5
commit
da8a9bb923
3 changed files with 49 additions and 0 deletions
27
app/cypress/e2e/caddy-media.cy.js
Normal file
27
app/cypress/e2e/caddy-media.cy.js
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue