From 6213de8946122c68878a175d620fa3ffb58f75ab Mon Sep 17 00:00:00 2001 From: Trevor Baron Date: Mon, 30 Dec 2019 07:47:55 -0800 Subject: [PATCH] Add back `--cors` option (#527) * add back cors option * fix linting * move above compress handler * Update serve.js --- bin/serve.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/serve.js b/bin/serve.js index 1e9672d3..daceb964 100755 --- a/bin/serve.js +++ b/bin/serve.js @@ -184,6 +184,9 @@ const startEndpoint = (endpoint, config, args, previous) => { const httpMode = args['--ssl-cert'] && args['--ssl-key'] ? 'https' : 'http'; const serverHandler = async (request, response) => { + if (args['--cors']) { + response.setHeader('Access-Control-Allow-Origin', '*'); + } if (compress) { await compressionHandler(request, response); } @@ -366,6 +369,7 @@ const loadConfig = async (cwd, entry, args) => { '--no-compression': Boolean, '--no-etag': Boolean, '--symlinks': Boolean, + '--cors': Boolean, '--ssl-cert': String, '--ssl-key': String, '-h': '--help', @@ -377,6 +381,7 @@ const loadConfig = async (cwd, entry, args) => { '-n': '--no-clipboard', '-u': '--no-compression', '-S': '--symlinks', + '-C': '--cors', // This is deprecated and only for backwards-compatibility. '-p': '--listen' });