Http-server: option to set custom response headers, example Service-Worker-Allowed

Created on 12 Dec 2016  路  8Comments  路  Source: http-party/http-server

option to set custom response headers, for instance Service-Worker-Allowed. possible add more then one custom headers to response.

Most helpful comment

yes, you are right, it is "a simple zero-configuration command-line http server" tool but it will be optional flag which turn on some custom headers. we can use -H/--header <header> which add custom header. example of use:
http-server ./folder -H "Custom-Header1:value1" -H "Custom-Header2:value2"
or
http-server ./folder -H "Custom-Header1:value1" "Custom-Header2:value2"
in this case we don't need to add custom flag each time to add custom headers.
What do you think?

All 8 comments

[personal opinion]

I'd like to remember that this project started of as a "a simple zero-configuration command-line http server". I can see however how this header is useful.

What about adding a --service-workers flag just like the --cors flag?

yes, you are right, it is "a simple zero-configuration command-line http server" tool but it will be optional flag which turn on some custom headers. we can use -H/--header <header> which add custom header. example of use:
http-server ./folder -H "Custom-Header1:value1" -H "Custom-Header2:value2"
or
http-server ./folder -H "Custom-Header1:value1" "Custom-Header2:value2"
in this case we don't need to add custom flag each time to add custom headers.
What do you think?

@Mirodil

I think that having a specific flag is good if there's enough use cases/users for it. In the --cors case, I'm pretty confident about that, in the services workers case I'm not sure.

The maintainers of this module will have to decide wether --header is a direction the want to go to with this project.

yes sure

Also want custom headers . cause I should serve sth like this https://github.com/zendesk/cross-storage#installation

I just proposed #360 which would solve for this...and potentially all the other (un)imagined uses for HTTP headers. :grin: Thoughts welcome!

the -H is much wanted option.. especially if you are dealing with iframes

I am right to understand that we can not use/develop web workers with http-server ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thornjad picture thornjad  路  5Comments

laughinghan picture laughinghan  路  5Comments

LeaVerou picture LeaVerou  路  5Comments

Altiano picture Altiano  路  7Comments

gerkirill picture gerkirill  路  3Comments