Last active
September 2, 2021 12:06
-
-
Save chrisjlee/1447ab1167326dba1d45 to your computer and use it in GitHub Desktop.
Gulp connect CORS https://github.com/AveVlad/gulp-connect/issues/100#issuecomment-96078162
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var connect = require('gulp-connect'); | |
var cors = function (req, res, next) { | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
res.setHeader('Access-Control-Allow-Headers', '*'); | |
next(); | |
}; | |
gulp.task('server:test', function () { | |
connect.server({ | |
root: 'dist', | |
livereload: true, | |
port: 9000, | |
middleware: function () { | |
return [cors]; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this resolved cors issues for me.