http-server icon indicating copy to clipboard operation
http-server copied to clipboard

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

Open Mirodil opened this issue 9 years ago • 8 comments

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

Mirodil avatar Dec 12 '16 13:12 Mirodil

[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?

derhuerst avatar Dec 12 '16 13:12 derhuerst

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 avatar Dec 12 '16 14:12 Mirodil

@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.

derhuerst avatar Dec 12 '16 14:12 derhuerst

yes sure

Mirodil avatar Dec 12 '16 14:12 Mirodil

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

lgh06 avatar Dec 28 '16 07:12 lgh06

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

BigBlueHat avatar Apr 25 '17 20:04 BigBlueHat

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

bchenSyd avatar Jun 06 '18 03:06 bchenSyd

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

distante avatar Jan 03 '19 13:01 distante