functions/index.js
function cors(req, res, next) {
  const port = process.env.NODE_ENV === 'production'
    ? null
    : new url.URL(req.query.__amp_source_origin).port;

  const host = process.env.NODE_ENV === 'production'
    ? `https://${req.hostname}`
    : `http://${req.hostname}:${port}`;

  res.header('amp-access-control-allow-source-origin', host);

  next();
}
function cors(req, res, next) {
  const port = process.env.NODE_ENV === 'production'
    ? null
    : new url.URL(req.query.__amp_source_origin).port;

  const host = process.env.NODE_ENV === 'production'
    ? `https://${req.hostname}`
    : `http://${req.hostname}:${port}`;

  res.header('amp-access-control-allow-source-origin', host);

  next();
}
function cors ( req , res , next ) { const port = process . env . NODE_ENV === 'production' ? null : new url . URL ( req . query . __amp_source_origin ) . port ; const host = process . env . NODE_ENV === 'production' ? ` ${ req . hostname } ` : ` ${ req . hostname } ${ port } ` ; res . header ( 'amp-access-control-allow-source-origin' , host ) ; next ( ) ; }
cors is HTTP middleware that sets an AMP-specific cross origin resource
sharing HTTP header on our response.

@param {Object} req - The HTTP request object.
@param {Object} res - The HTTP response object.
@param {Function} next - The next HTTP handler to execute.
cors is HTTP middleware that sets an AMP - specific cross origin resource sharing HTTP header on our response .