Skip to content

Demonstration of using server-side includes to inject runtime configuration to a single-page app

License

Notifications You must be signed in to change notification settings

textbook/spa-config-ssi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SPA Config SSI

Demonstration of using server-side includes to inject runtime configuration to a single-page app.

Notes

  • Bootstrapped using Create React App
  • Requires html-minifier-terser of at least 5.1.0 (see this Pull Request) or explicit configuration to leave SSI comments in HTML (can be done via webpack-html-plugin but not in CRA)
  • Set up for deployment to Cloud Foundry

Usage

This demo includes two sets of configuration:

  • development (in src/configuration.js); and
  • production (in public/config.html).

The SSI directive in public/index.html is replaced by the content of public/config.html at runtime, if SSI is enabled on the server (the included Staticfile does this for the Nginx used in the Staticfile buildpack).

To run locally with the development configuration:

npm start

To deploy to CF with the production configuration, using the CF CLI:

npm run build && cf push