javascript - gulp browser-sync not serving json files -


i have issue not able serve json files sub-folders. below code:

var browsersync = require('browser-sync').create();  // static server gulp.task('connect', function() {     browsersync.init({       server: {         basedir: "app/"       }     }); }); 

all static , angularjs files reside inside app folder. when navigate http://localhost:3000, page loads corresponding json file inside app/data/myfile.json not load.

i below error in console:

post http://localhost:3000/data/json/myfile.json 404 (not found)

the strange thing when try load path in browser, json file loads.

at first used way https://www.browsersync.io/docs/options/#option-servestatic fail.

const asset_extension_regex = new regexp(`\\b(?!\\?)\\.(${config.assetextensions.join('|')})\\b(?!\\.)`, 'i');      const default_file = 'index.html'; ...         server: {           basedir: './build',           middleware: function(req, res, next) {             let filehref = url.parse(req.url).href;              if ( !asset_extension_regex.test(filehref) ) {               req.url = '/' + default_file;             }              return next();           }         }      ... 

config = {assetextensions: [ 'js', 'css', 'png', 'jpe?g', 'gif', 'svg', 'eot', 'otf', 'ttc', 'ttf', 'json', 'woff2?' ]}

success


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -