function corsOptionsDelegate(req, cb) {
    const origin = req.get('origin');

    // Request must have an Origin header
    if (!origin || origin === 'null') {
        return cb(null, DISABLE_CORS);
    }

    // Origin matches allowlist
    if (getAllowlist().indexOf(url.parse(origin).hostname) > -1) {
        return cb(null, ENABLE_CORS);
    }

    return cb(null, DISABLE_CORS);
}
Checks the origin and enables/disables CORS headers in the response.
@param  {Object}   req express request object.
@param  {Function} cb  callback that configures CORS.
@return {null}