Skip to content

Commit

Permalink
LOCAL_HTTPS support (with HMR) through ngrok and JS_URL (#1290)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Jul 28, 2020
1 parent efcfad4 commit 9265ba2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions posthog/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def get_bool_from_env(name: str, default_value: bool) -> bool:
dsn=os.environ["SENTRY_DSN"], integrations=[DjangoIntegration()], request_bodies="always",
)

if get_bool_from_env("LOCAL_HTTPS", False):
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = True

if get_bool_from_env("DISABLE_SECURE_SSL_REDIRECT", False):
SECURE_SSL_REDIRECT = False
SESSION_COOKIE_SECURE = False
Expand Down
13 changes: 9 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function createEntry(entry) {
publicPath:
process.env.NODE_ENV === 'production'
? '/static/'
: process.env.JS_URL
? `${process.env.JS_URL}${process.env.JS_URL.endsWith('/') ? '' : '/'}static/`
: process.env.IS_PORTER
? `https://${process.env.PORTER_WEBPACK_HOST}/static/`
: `http${process.env.LOCAL_HTTPS ? 's' : ''}://${webpackDevServerHost}:8234/static/`,
Expand Down Expand Up @@ -162,9 +164,12 @@ function createEntry(entry) {
port: 8234,
noInfo: true,
stats: 'minimal',
public: process.env.IS_PORTER
? `https://${process.env.PORTER_WEBPACK_HOST}`
: `http${process.env.LOCAL_HTTPS ? 's' : ''}://${webpackDevServerHost}:8234`,
disableHostCheck: !!process.env.LOCAL_HTTPS,
public: process.env.JS_URL
? new URL(process.env.JS_URL).host
: process.env.IS_PORTER
? `${process.env.PORTER_WEBPACK_HOST}`
: `${webpackDevServerHost}:8234`,
allowedHosts: process.env.IS_PORTER
? [`${process.env.PORTER_WEBPACK_HOST}`, `${process.env.PORTER_SERVER_HOST}`]
: [],
Expand Down Expand Up @@ -204,7 +209,7 @@ function createEntry(entry) {
? [
new MiniCssExtractPlugin({
filename: '[name].css',
ignoreOrder: true
ignoreOrder: true,
}),
new HtmlWebpackPlugin({
alwaysWriteToDisk: true,
Expand Down

0 comments on commit 9265ba2

Please sign in to comment.