What is the way to configure/override how certain MIME types are handled?
For example, with the default configuration a python file (.py
) is served with Content-disposition": attachment
which opens a file save dialog rather than displaying inline plain text in the browser.
I've identified one possible approach:
@py {
path *.py
}
header @py Content-Type text/plain
While this works, it looks more of a hack rather than adding/modifying a mime type, given that it's simply setting a header based on a substring match. Is this the only possible approach?
What defines that a specific MIME type should be served inline or have "Content-disposition": attachment
? Does caddy expose a straightforward way to configure how MIME types are handled?
The correct mime type for .py
files is application/x-python-code
or text/x-python
. How can I configure caddy to treat these types as inline plain text, and not add the Content-disposition": attachment
header? Forcing text/plain
works as a workaround, but I am assuming there is a cleaner way to do it.