Skip to content

Commit 6213de8

Browse files
TrevorDevleo
authored andcommitted
Add back --cors option (vercel#527)
* add back cors option * fix linting * move above compress handler * Update serve.js
1 parent cbc6c4a commit 6213de8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

bin/serve.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ const startEndpoint = (endpoint, config, args, previous) => {
184184
const httpMode = args['--ssl-cert'] && args['--ssl-key'] ? 'https' : 'http';
185185

186186
const serverHandler = async (request, response) => {
187+
if (args['--cors']) {
188+
response.setHeader('Access-Control-Allow-Origin', '*');
189+
}
187190
if (compress) {
188191
await compressionHandler(request, response);
189192
}
@@ -366,6 +369,7 @@ const loadConfig = async (cwd, entry, args) => {
366369
'--no-compression': Boolean,
367370
'--no-etag': Boolean,
368371
'--symlinks': Boolean,
372+
'--cors': Boolean,
369373
'--ssl-cert': String,
370374
'--ssl-key': String,
371375
'-h': '--help',
@@ -377,6 +381,7 @@ const loadConfig = async (cwd, entry, args) => {
377381
'-n': '--no-clipboard',
378382
'-u': '--no-compression',
379383
'-S': '--symlinks',
384+
'-C': '--cors',
380385
// This is deprecated and only for backwards-compatibility.
381386
'-p': '--listen'
382387
});

0 commit comments

Comments
 (0)