Doesn't work when using the "proxy" config
See original GitHub issueHere are my configs:
{
"proxy": "localhost:5000",
"port": 7000
}
When I run the command without "proxy": "localhost:5000"
, an instance of Chrome opens on localhost:7000
as expected and everything is fine. With "proxy": "localhost:5000"
, it shows:
** browser-sync config **
{ injectChanges: false,
files: [ './**/*.{html,htm,css,js}' ],
watchOptions: { ignored: 'node_modules' },
server: { baseDir: './', middleware: [ [Function], [Function] ] },
logLevel: 'silent',
proxy: 'localhost:5000',
port: 7000 }
in the terminal and the process exits.
I tested a bit with some console.log
s in lite-server.js
:
console.log('executed');
browserSync.init(config, cb);
console.log('not executed');
Versions:
lite-server
version: 2.2.0nodejs
version: 5.9.1npm
version: 3.7.3- OS type/version: OSX El Capitan 10.11.3
Update
I gave version 2.1.0
a try and this time I got much clearer indications: Invalid config. You cannot specify both server & proxy options
.
When merging the default config and the custom config, proxy
and server
are put together in the same set of configurations.
To temporarily fix my problem, I replaced
if (config.server.middleware) {
config.server.middleware = _.compact(config.server.middleware);
}
by:
delete config.server;
So there are two problems:
- The outputs from
browser-sync
are not being displayed in the terminal (They are displayed in 2.1.0. but not 2.2.0). This includesInvalid config. You cannot specify both server & proxy options
, but also the message telling me to add
<script id="__bs_script__">//<![CDATA[
// document.write("<script async src='http://HOST:3000/browser-sync/browser-sync- client.2.11.2.js'><\/script>".replace("HOST", location.hostname));
// //]]></script>
before the closing tag of the body
when the application actually launches in proxy mode.
2. There is a conflict between the default server
config and the proxy
config.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8
Top GitHub Comments
Glad it is working! BTW, there were some recent issues with proxy mode that are fixed in Browsersync
2.12.2+
(see #71).To remove the request logging, there’s an example in the README:
The
proxy
andserver
configs in browsersync are mutually exclusive. The current lite-server always usesserver
in the config, so browsersync fails when includingproxy
config.When trying the following
bs-config.json
with Browsersync (without lite-server), it proxies as expected:But as soon as you add
server
config, it fails with an error:@maximedupre could you describe your use-case a bit more? Curious how beneficial it would be for lite-server to support proxy mode vs. using browsersync itself.