From 79bd3e7f144e963de179ca0b92c2e9b410eb087d Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Fri, 17 Dec 2021 17:53:43 +0000 Subject: [PATCH] Fix BrowserSync config on non-Docker setup (#3461) --- {{cookiecutter.project_slug}}/gulpfile.js | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/{{cookiecutter.project_slug}}/gulpfile.js b/{{cookiecutter.project_slug}}/gulpfile.js index 387a137a..82d66fc8 100644 --- a/{{cookiecutter.project_slug}}/gulpfile.js +++ b/{{cookiecutter.project_slug}}/gulpfile.js @@ -133,31 +133,31 @@ function runServer(cb) { // Browser sync server for live reload function initBrowserSync() { - browserSync.init( - [ - `${paths.css}/*.css`, - `${paths.js}/*.js`, - `${paths.templates}/*.html` - ], { - // https://www.browsersync.io/docs/options/#option-proxy + browserSync.init( + [ + `${paths.css}/*.css`, + `${paths.js}/*.js`, + `${paths.templates}/*.html` + ], { + // https://www.browsersync.io/docs/options/#option-proxy + proxy: { {%- if cookiecutter.use_docker == 'n' %} - proxy: 'localhost:8000' + proxy: '127.0.0.1:8000', {%- else %} - proxy: { - target: 'django:8000', - proxyReq: [ - function(proxyReq, req) { - // Assign proxy "host" header same as current request at Browsersync server - proxyReq.setHeader('Host', req.headers.host) - } - ] - }, // https://www.browsersync.io/docs/options/#option-open // Disable as it doesn't work from inside a container - open: false + open: false, + target: 'django:8000', {%- endif %} + proxyReq: [ + function(proxyReq, req) { + // Assign proxy "host" header same as current request at Browsersync server + proxyReq.setHeader('Host', req.headers.host) + } + ] } - ) + } + ) } // Watch