This is MDN's HTTP request handler, deployed using Cloud Functions behind Cloud CDN. It mostly proxies requests and handles some special routes directly.
Run npm start to serve the Cloud Function at http://localhost:7100/.
By default, it will use your local client/build directory, serving it at
http://localhost:8100/, and proxy API requests to the stage API at
https://developer.allizom.org/.
Set SOURCE_API=http://localhost:8000/ in your .env.
To use Glean, the Cloud Function must be accessed via HTTPS. Otherwise the Glean.js SDK throws an uncaught error that prevents execution of JavaScript.
We recommend using mkcert to create a
locally-trusted development certificate. Add the key and certificate paths as
HTTPS_KEY_FILE and HTTPS_CERT_FILE variables to your .env file. This will
automatically enable an HTTPS proxy at https://localhost/ in addition to
http://localhost:7100/.
The function uses the following environment variables:
ORIGIN_MAIN(default:"localhost") - The expectedHostheader value for requests to the main site.ORIGIN_LIVE_SAMPLES(default:"localhost") - The expectedHostheader value for requests to live samples.SOURCE_CONTENT(default:"http://localhost:8100") - The URL at which the client build is served.SOURCE_API(default:"https://developer.allizom.org/") - The URL at which the API is served.REVIEW_ROUTING(default:false) - If enabled, accepts anyHostheader value, uses the leftmost subdomain to route into a subdirectory ofSOURCE_CONTENT, and falls back to production for missing assets.CACHE_DISABLED(default:false) - If enabled, disables response caching (Cache-Control: no-storefor non-hashed 200 responses, and skips the in-memory 404 cache).
The placement handler uses the following environment variables:
SIGN_SECRET(default:"") - Required for serving placements.
You can override the defaults by adding a .env file with KEY=value lines.