W
W
web-developer20192020-02-22 13:36:16
gulp.js
web-developer2019, 2020-02-22 13:36:16

Can't run browserSync in gulp due to Content Security Policy in Chrome browser?

When the task is started, a page opens in the browser with the message "Cannot GET /"

5e51033ce8830867561909.jpeg

Console
5e510361ad850257770709.jpeg

screen: Task code:

const gulp = require('gulp');
const browserSync = require('browser-sync').create();

gulp.task('server', function() {
    browserSync.init({
        server: {
            baseDir: "app/*.html"
        }
    });
});


Help solve the problem! I don't understand why lecturers in video courses don't have these problems..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
granty, 2020-02-22
@granty

You have a header somewhere on the server: Either through PHP-shnuyu , or the header is registered in .htaccess or in the Apache / nginx / Denver config tp. Technically, browser extensions/plugins, including malicious ones, can also publish it . Either remove this header entirely, or add a script-src directive to it :
Content-Security-Policy: default-src 'self';

Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' appmakedev.xyz linkangood.com;

Also, you have 8 pictures loaded, but they have the wrong src: . When you specify it correctly, you will have to add a directive to the CSP header img-src 'self'(and possibly add the domains from which you upload images).
If you do not remove the header, then you will add to this header all third-party hosts (domains) from which you download scripts and pictures (and CSS styles, and fonts, and much more).
PS: It's strange that you roll the barrel only on Chrome, it should be the same in Firefox. Unless, of course, you have a Content-Security-Policy: default-src 'self';non-browser plug-in.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question