From c5d1446e35f21482661ea6bff6c989e89aa858a8 Mon Sep 17 00:00:00 2001 From: bfc <846958672@qq.com> Date: Sun, 28 Apr 2024 19:05:39 +0800 Subject: [PATCH] support custom response headers --- bin/http-server | 2 ++ lib/http-server.js | 1 + 2 files changed, 3 insertions(+) diff --git a/bin/http-server b/bin/http-server index 7c597fa8a..ad01a1d13 100755 --- a/bin/http-server +++ b/bin/http-server @@ -27,6 +27,7 @@ if (argv.h || argv.help) { ' -p --port Port to use. If 0, look for open port. [8080]', ' -a Address to use [0.0.0.0]', ' -d Show directory listings [true]', + ' -H --headers add response headers e.g.: --headers=Cross-Origin-Opener-Policy:same-origin', ' -i Display autoIndex [true]', ' -g --gzip Serve gzip files when possible [false]', ' -b --brotli Serve brotli files when possible [false]', @@ -138,6 +139,7 @@ else { function listen(port) { var options = { + H: argv.headers || argv.header || argv.H, root: argv._[0], cache: argv.c, timeout: argv.t, diff --git a/lib/http-server.js b/lib/http-server.js index dfe4c474c..14ca4aeb3 100644 --- a/lib/http-server.js +++ b/lib/http-server.js @@ -126,6 +126,7 @@ function HttpServer(options) { } before.push(httpServerCore({ + H: options.H, root: this.root, cache: this.cache, showDir: this.showDir,