pm2 serve: add e-book MIME types
Author: PixelQuasarCreated Sep 1, 2026Updated Sep 1, 2026
Description
Currently, the MIME table in lib/API/Serve.js doesn't cover e-book formats: epub, fb2, mobi, azw3. Since anything not in the table is served as text/plain, an .epub served by pm2 serve arrives labelled as text: the browser renders the zip bytes instead of downloading the file, and readers that dispatch on Content-Type do not recognise it.
Reproduction
mkdir -p /tmp/serve-demo && cd /tmp/serve-demo
printf 'PK\x03\x04' > book.epub
printf 'PK\x03\x04' > book.pdf
pm2 serve . 8080
curl -sI http://localhost:8080/book.epub | grep -i content-type # text/plain
curl -sI http://localhost:8080/book.pdf | grep -i content-type # application/pdfSuggested change
Four entries in contentTypes:
'epub': 'application/epub+zip',
'fb2': 'application/x-fictionbook+xml',
'mobi': 'application/x-mobipocket-ebook',
'azw3': 'application/vnd.amazon.mobi8-ebook',Happy to open a PR if the change looks welcome.
Source: Unitech/pm2