Skip to content

Commit 56e39f8

Browse files
committed
Add comments about __SERVER_DATA__
1 parent 161a890 commit 56e39f8

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

scripts/build.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Do this as the first thing so that any code reading it knows the right env.
44
process.env.NODE_ENV = 'production';
55

6+
// Use dynamic server data in production by inserting a token that will be
7+
// replaced when the HTML page is served.
68
process.env.REACT_APP_SERVER_DATA = '__SERVER_DATA__';
79

810
// Load environment variables from .env file. Suppress warnings using silent

scripts/start.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
process.env.NODE_ENV = 'development';
44

5+
// Use static server data in development.
56
process.env.REACT_APP_SERVER_DATA = JSON.stringify(require('../server/dev-data'))
67

78
// Load environment variables from .env file. Suppress warnings using silent

server/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const sendHomePage = (publicDir) => {
1919
} else {
2020
res.set('Cache-Control', 'public, max-age=60')
2121
res.send(
22+
// Replace the __SERVER_DATA__ token that was added to the
23+
// HTML file in the build process (see scripts/build.js).
2224
html.replace('__SERVER_DATA__', JSON.stringify({
2325
cloudflareStats: stats
2426
}))

0 commit comments

Comments
 (0)