Home > Web Front-end > JS Tutorial > body text

Examples of gulp solving cross-domain problems

零下一度
Release: 2017-06-26 11:39:42
Original
2619 people have browsed it
//引入插件var gulp = require('gulp');// var Proxy = require('gulp-connect-proxy');var connect = require('gulp-connect');var proxy = require('http-proxy-middleware');//使用connect启动一个Web服务器gulp.task('connect', function () {
    connect.server({
        root: './',
        livereload: true,
        port: 8010,
        middleware: function (connect, opt) {return [
                proxy('/fs', {
                    target: 'http://172.16.2.52:8080',
                    changeOrigin:true}),
                proxy('/product', {
                    target: 'http://172.16.1.60:8080',
                    changeOrigin:true}),
                proxy('/bpauth', {
                    target: 'http://192.168.24.77:8080',
                    changeOrigin:true})
            ]
        }
    });
});

gulp.task('watch', function () {
    gulp.watch(['./*.html'], ['html']);

});

gulp.task('html', function () {
    gulp.src('./*.html')
        .pipe(connect.reload());
});//运行Gulp时,默认的Taskgulp.task('default', ['connect', 'watch']);
Copy after login

 

The above is the detailed content of Examples of gulp solving cross-domain problems. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template