I know Express has the res.contentType() method, but how do I automatically set content type based on path/file (including static content)?
I know Express has the res.contentType() method, but how do I automatically set content
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Connect will automatically set the content type, unless you explicitly set it yourself. Here’s the snippet that does it. It uses mime.lookup and mime.charsets.lookup
If this isn’t working for you, post your code as your custom code is likely interfering with the default behavior somehow.