expressjs.com icon indicating copy to clipboard operation
expressjs.com copied to clipboard

Mime type changes to sendFile function

Open jschweik opened this issue 8 months ago • 1 comments

Description

While migrating from Express 4 to Express 5, we noticed that our previous call to sendFile('foo.js'); was returning the mime type of "text/javascript" for Express 5 vs the previous Express 4 "application/javascript".

Expectations

While the Express 5 migration document clearly stated the move from 'express.static.mime' to the 'mime-types' package, it didn't elaborate that might have unexpected consequences even for those that were not directly using 'express.static.mime' by other methods such as 'sendFile' that is supported in both Express 4 and 5 can return different content type headers than expected because 'mime-types' is using a different value.

This might only be isolated to 'text/javascript' and 'application/javascript', but a full comparison of the two might yield other type differences that users should be aware of.

Making this more clear in either the mime section or the sendFile section would help migrators.

Thanks.

jschweik avatar Apr 21 '25 21:04 jschweik

Pull requests are welcome

bjohansebas avatar Apr 22 '25 01:04 bjohansebas