BrowserSync / browser-sync

Keep multiple browsers & devices in sync when building websites. https://browsersync.io
https://discord.gg/2d2xUThp
Apache License 2.0
12.15k stars 754 forks source link

Browsersync client script not injected when proxying through Cloudflare Zero Trust #1988

Open husterk opened 1 year ago

husterk commented 1 year ago

Issue details

I have a local development website (e.g. http://localhost:2368) that is proxied through a Cloudflare Zero Trust tunnel (e.g. https://my-proxied-site.com). When I set up browsersync (proxy mode) to target the http://localhost:2368 site directly then everything works and the browser instances are registered with browsersync. However, when I set up browsersync (proxy mode) to target the Cloudflare proxied site at https://my-proxied-site.com then the browser instances fail to connect to browsersync. Upon inspection, I do not see the necessary browsersync scripts being injected into the site.

I have attempted to implement a bypass rule for all traffic to my-proxied-site.com to ensure that the Cloudflare gateway policies aren't blocking any connection attempts. However, this did not help.

Steps to reproduce/test case

See notes above.

Please specify which version of Browsersync, node and npm you're running

Affected platforms

Browsersync use-case

If CLI, please paste the entire command below

None

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

import { create as createBrowserSync } from "browser-sync";

const browserSync = createBrowserSync();

browserSync.init({
        proxy: {
            target: "https://my-proxied-site.com",  // THIS DOES NOT WORK
            //target: "http://localhost:2368",           // THIS WORKS
        },
        port: 8443,
        open: false,
        logLevel: "debug",
        logConnections: true,
    });
shakyShane commented 1 year ago

Quick question - does the site in question have a 'body' tag?

husterk commented 1 year ago

Quick question - does the site in question have a 'body' tag?

Yes, it does have a <body></body> tag.