Fix email links when using Docker with Gulp

This commit is contained in:
Bruno Alla 2019-03-21 13:25:48 +00:00
parent 52eebeea1d
commit 7e96773d6e
3 changed files with 15 additions and 5 deletions

View File

@ -11,7 +11,7 @@ SECRET_KEY = env(
default="!!!SET DJANGO_SECRET_KEY!!!",
)
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ["localhost",{% if cookiecutter.js_task_runner == 'Gulp' and cookiecutter.use_docker == 'y' %} "django",{% endif %} "0.0.0.0", "127.0.0.1"]
ALLOWED_HOSTS = ["localhost", "0.0.0.0", "127.0.0.1"]
# CACHES
# ------------------------------------------------------------------------------

View File

@ -127,12 +127,21 @@ function initBrowserSync() {
`${paths.js}/*.js`,
`${paths.templates}/*.html`
], {
// https://www.browsersync.io/docs/options/#option-proxy
{%- if cookiecutter.use_docker == 'n' %}
proxy: "localhost:8000"
proxy: 'localhost:8000'
{% else %}
proxy: "django:8000",
// Browsersync may open the browser when ready, but it doesn't work from
// inside a container, so set this option to false
proxy: {
target: 'django:8000',
proxyReq: [
function(proxyReq) {
// Set to the browsersync host & port to have email links working
proxyReq.setHeader('Host', 'localhost:3000')
}
]
}
// https://www.browsersync.io/docs/options/#option-open
// Disable as it doesn't work from inside a container
open: false
{%- endif %}
}

View File

@ -95,6 +95,7 @@ services:
command: npm run dev
ports:
- "3000:3000"
# Expose browsersync UI: https://www.browsersync.io/docs/options/#option-ui
- "3001:3001"
{%- endif %}