lib/plugin/cors.js
function restifyCORSSimple(req, res, next) {
    var origin;
    if (!(origin = matchOrigin(req, origins))) {
      next();
      return;
    }

    function corsOnHeader() {
      origin = req.headers.origin;

      if (opts.credentials) {
        res.setHeader(AC_ALLOW_CREDS, 'true');
      }

      res.setHeader(AC_ALLOW_ORIGIN, origin);
      res.setHeader(AC_EXPOSE_HEADERS, headers.join(', '));
      res.setHeader(AC_ALLOW_METHODS, ALLOW_METHODS.join(', '));
      res.setHeader(AC_ALLOW_HEADERS, ALLOW_HEADERS.join(', '));
      res.setHeader(AC_REQUEST_HEADERS, REQUEST_HEADERS.join(', '));
    }

    res.once('header', corsOnHeader);
    next();
  }
function restifyCORSSimple(req, res, next) {
    var origin;
    if (!(origin = matchOrigin(req, origins))) {
      next();
      return;
    }

    function corsOnHeader() {
      origin = req.headers.origin;

      if (opts.credentials) {
        res.setHeader(AC_ALLOW_CREDS, 'true');
      }

      res.setHeader(AC_ALLOW_ORIGIN, origin);
      res.setHeader(AC_EXPOSE_HEADERS, headers.join(', '));
      res.setHeader(AC_ALLOW_METHODS, ALLOW_METHODS.join(', '));
      res.setHeader(AC_ALLOW_HEADERS, ALLOW_HEADERS.join(', '));
      res.setHeader(AC_REQUEST_HEADERS, REQUEST_HEADERS.join(', '));
    }

    res.once('header', corsOnHeader);
    next();
  }
function restifyCORSSimple ( req , res , next ) { var origin ; if ( ! ( origin = matchOrigin ( req , origins ) ) ) { next ( ) ; return ; } function corsOnHeader ( ) { origin = req . headers . origin ; if ( opts . credentials ) { res . setHeader ( AC_ALLOW_CREDS , 'true' ) ; } res . setHeader ( AC_ALLOW_ORIGIN , origin ) ; res . setHeader ( AC_EXPOSE_HEADERS , headers . join ( ', ' ) ) ; res . setHeader ( AC_ALLOW_METHODS , ALLOW_METHODS . join ( ', ' ) ) ; res . setHeader ( AC_ALLOW_HEADERS , ALLOW_HEADERS . join ( ', ' ) ) ; res . setHeader ( AC_REQUEST_HEADERS , REQUEST_HEADERS . join ( ', ' ) ) ; } res . once ( 'header' , corsOnHeader ) ; next ( ) ; }
Handler for simple requests
Handler for simple requests