BrowserSync + gulp: Cors cross domain issue
I am working on a project where my workspace is located directly on a remote server.
So far I am loading browser sync using my own ip in the src file:
<script type='text/javascript' id="__bs_script__">//<![CDATA[
document.write("<script async src='MYIP:3000/browser-sync/browser-sync-client.1.9.2.js'><\/script>".replace(/HOST/g, location.hostname).replace(/PORT/g, location.port));//]]></script>
But I am facing a cross-origin request issue.
Any idea how to set up my gulp?
browserSync({files: [constants.CSS_FOLDER+"/**/*.css"]});
Thank!
+3
source to share
1 answer
I'm not sure I fully understand what you are trying to do, but you can add middleware to BrowserSync and there you can add whatever header you want.
It will look something like this:
browserSync({
server: {
baseDir: './build',
middleware: function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
next();
}
}
});
+11
source to share