BrowserSync / browser-sync

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

Proxy mangles URL strings in JSON #2016

Open Thomaash opened 1 year ago

Thomaash commented 1 year ago

Issue details

The URL rewriting sometimes eats a backslash following the URL, causing syntax errors.

Steps to reproduce/test case

Add the following to an HTML file served from 127.0.0.1:8887:

<script>
  console.log("[\"baseUrl\",\"127.0.0.1:8887\"]");
  console.log("[\"baseUrl\",\"//127.0.0.1:8887\"]");
  console.log("[\"baseUrl\",\"http://127.0.0.1:8887\"]");
</script>

and on localhost:3000 you get:

<script>
  console.log("[\"baseUrl\",\"//localhost:3000"]");
  console.log("[\"baseUrl\",\"//localhost:3000\"]");
  console.log("[\"baseUrl\",\"//localhost:3000"]");
</script>

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

Affected platforms

Browsersync use-case

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({
  host: "127.0.0.1",
  port: 3000,
  proxy: "127.0.0.1:8887",
});