Merge pull request #150 from pirxpilot/no-cors
add `--cors` option to allow for optional CORS handling
This commit is contained in:
commit
49a779970e
2 changed files with 9 additions and 2 deletions
|
@ -32,6 +32,10 @@ var opts = require('nomnom')
|
||||||
default: 8080,
|
default: 8080,
|
||||||
help: 'Port'
|
help: 'Port'
|
||||||
})
|
})
|
||||||
|
.option('cors', {
|
||||||
|
default: true,
|
||||||
|
help: 'Enable Cross-origin resource sharing headers'
|
||||||
|
})
|
||||||
.option('verbose', {
|
.option('verbose', {
|
||||||
abbr: 'V',
|
abbr: 'V',
|
||||||
flag: true,
|
flag: true,
|
||||||
|
@ -54,7 +58,8 @@ var startServer = function(configPath, config) {
|
||||||
configPath: configPath,
|
configPath: configPath,
|
||||||
config: config,
|
config: config,
|
||||||
bind: opts.bind,
|
bind: opts.bind,
|
||||||
port: opts.port
|
port: opts.port,
|
||||||
|
cors: opts.cors
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,9 @@ module.exports = function(opts, callback) {
|
||||||
|
|
||||||
var data = clone(config.data || {});
|
var data = clone(config.data || {});
|
||||||
|
|
||||||
|
if (opts.cors) {
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
|
}
|
||||||
|
|
||||||
Object.keys(config.styles || {}).forEach(function(id) {
|
Object.keys(config.styles || {}).forEach(function(id) {
|
||||||
var item = config.styles[id];
|
var item = config.styles[id];
|
||||||
|
|
Loading…
Reference in a new issue