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 expectedHost
header value for requests to the main site.ORIGIN_LIVE_SAMPLES
(default:"localhost"
) - The expectedHost
header 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.
The placement handler uses the following environment variables:
KEVEL_SITE_ID
(default:0
) - Required for serving placements via Kevel.KEVEL_NETWORK_ID
(default:0
) - Required for serving placements via Kevel.SIGN_SECRET
(default:""
) - Required for serving placements.CARBON_ZONE_KEY
(default:""
) - Required for serving placements via Carbon.CARBON_FALLBACK_ENABLED
(default:"false"
) - Whether fallback placements should be served via Carbon.
You can override the defaults by adding a .env
file with KEY=value
lines.