Skip to content

Commit d25e95f

Browse files
Fix TypeError
: Cannot read properties of undefined (reading 'HOSTNAME')
1 parent 53220c6 commit d25e95f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

dotcom-rendering/.storybook/main.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ const config: StorybookConfig = {
4545
config.resolve.fallback['http'] = false;
4646
config.resolve.fallback['https'] = false;
4747
config.resolve.fallback['os'] = false;
48-
// Provide browser polyfill for 'path' (used indirectly by clean-css)
49-
config.resolve.fallback['path'] = require.resolve('path-browserify');
50-
// Explicitly disable 'fs' since clean-css conditionally touches it; we don't need it in the browser
51-
config.resolve.fallback['fs'] = false;
5248

5349
// Required as otherwise 'process' will not be defined when included on its own (without .env)
5450
// e.g process?.env?.SOME_VAR

dotcom-rendering/src/lib/braze/forceBrazeMessage.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
const runtimeHostname = () => {
2-
if (typeof process !== 'undefined' && process.env.HOSTNAME)
3-
return process.env.HOSTNAME;
4-
if (typeof window !== 'undefined') return window.location.hostname;
5-
return 'localhost';
2+
try {
3+
if (typeof process !== 'undefined' && process.env.HOSTNAME) {
4+
return process.env.HOSTNAME;
5+
}
6+
} catch {
7+
/* ignore */
8+
}
9+
if (typeof window !== 'undefined' && window.location.hostname) {
10+
return window.location.hostname;
11+
}
612
};
713

814
const FORCE_BRAZE_ALLOWLIST = [

0 commit comments

Comments
 (0)