我正在尝试使用 gulp 和浏览器同步重定向我的 API 请求:
gulp.task('browser-sync', function () {
var files = [
'../index.html',
'../views/**/*.html',
'../assets/css/**/*.css',
'../assets/js/**/*.js'
];
var url = require('url'),
proxy = require('proxy-middleware');
var proxyOptions = url.parse('http://localhost:8000/api');
proxyOptions.route = '/api';
browserSync.init(files, {
server: {
baseDir: '..',
middleware: [proxy(proxyOptions)]
}
});
});
但是当调用被发送到 API 时,我得到了这个响应:
Error: connect ECONNREFUSED
at errnoException (net.js:904:11)
at Object.afterConnect [as oncomplete] (net.js:895:19)
知道我做错了什么吗?