September 2018
Beginner
156 pages
3h 28m
English
The last step is to update the server-side code to include the client-side bundle (bundle.js) as part of the first response. The server-side code can include a <script> tag which specifies the bundle.js file in the source (src) attribute:
res.send(` <!DOCTYPE HTML> <html> <head> <title>React SSR example</title> <script src='/bundle.js' defer></script> ... </html>`);
Also, for our express server to serve a JavaScript file, we include the middleware function for serving static content:
app.use(express.static('dist/public'))
The preceding code allows static files such as JavaScript files, CSS files, and Images, to be served from the dist/public directory. The preceding statement should be included before app.get() ...
Read now
Unlock full access