Skip to content

Commit

Permalink
adeded mimeTypes option
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerard Rodes authored and thgh committed Aug 27, 2020
1 parent 1673bde commit face777
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ serve({
headers: {
'Access-Control-Allow-Origin': '*',
foo: 'bar'
},

// set custom mime types, usage https://github.com/broofa/mime#mimedefinetypemap-force--false
mimeTypes: {
'application/javascript': ['js_commonjs-proxy']
}
})
```
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function serve (options = { contentBase: '' }) {
options.openPage = options.openPage || ''
mime.default_type = 'text/plain'

if (options.mimeTypes) {
mime.define(options.mimeTypes)
}

const requestListener = (request, response) => {
// Remove querystring
const unsafePath = decodeURI(request.url.split('?')[0])
Expand Down

0 comments on commit face777

Please sign in to comment.