cors(options) {
    const opts = typeof options === 'object' ? options : {}

    // Check for existing headers
    let acao = this.getHeader('Access-Control-Allow-Origin')
    let acam = this.getHeader('Access-Control-Allow-Methods')
    let acah = this.getHeader('Access-Control-Allow-Headers')

    // Default CORS headers
    this.header('Access-Control-Allow-Origin', opts.origin ? opts.origin : (acao ? acao : '*'))
    this.header('Access-Control-Allow-Methods', opts.methods ? opts.methods : (acam ? acam : 'GET, PUT, POST, DELETE, OPTIONS'))
    this.header('Access-Control-Allow-Headers', opts.headers ? opts.headers : (acah ? acah : 'Content-Type, Authorization, Content-Length, X-Requested-With'))

    // Optional CORS headers
    if (opts.maxAge && !isNaN(opts.maxAge)) this.header('Access-Control-Max-Age', (opts.maxAge / 1000 | 0).toString())
    if (opts.credentials) this.header('Access-Control-Allow-Credentials', opts.credentials.toString())
    if (opts.exposeHeaders) this.header('Access-Control-Expose-Headers', opts.exposeHeaders)

    return this
  }
// Convenience method for setting CORS headers
Convenience method for setting CORS headers
Convenience method for setting CORS headers
cors(options) {
    const opts = typeof options === 'object' ? options : {}
    let acao = this.getHeader('Access-Control-Allow-Origin')
    let acam = this.getHeader('Access-Control-Allow-Methods')
    let acah = this.getHeader('Access-Control-Allow-Headers')
    this.header('Access-Control-Allow-Origin', opts.origin ? opts.origin : (acao ? acao : '*'))
    this.header('Access-Control-Allow-Methods', opts.methods ? opts.methods : (acam ? acam : 'GET, PUT, POST, DELETE, OPTIONS'))
    this.header('Access-Control-Allow-Headers', opts.headers ? opts.headers : (acah ? acah : 'Content-Type, Authorization, Content-Length, X-Requested-With'))
    if (opts.maxAge && !isNaN(opts.maxAge)) this.header('Access-Control-Max-Age', (opts.maxAge / 1000 | 0).toString())
    if (opts.credentials) this.header('Access-Control-Allow-Credentials', opts.credentials.toString())
    if (opts.exposeHeaders) this.header('Access-Control-Expose-Headers', opts.exposeHeaders)
    return this
  }
cors ( options ) { const opts = typeof options === 'object' ? options : { } let acao = this . getHeader ( 'Access-Control-Allow-Origin' ) let acam = this . getHeader ( 'Access-Control-Allow-Methods' ) let acah = this . getHeader ( 'Access-Control-Allow-Headers' ) this . header ( 'Access-Control-Allow-Origin' , opts . origin ? opts . origin : ( acao ? acao : '*' ) ) this . header ( 'Access-Control-Allow-Methods' , opts . methods ? opts . methods : ( acam ? acam : 'GET, PUT, POST, DELETE, OPTIONS' ) ) this . header ( 'Access-Control-Allow-Headers' , opts . headers ? opts . headers : ( acah ? acah : 'Content-Type, Authorization, Content-Length, X-Requested-With' ) ) if ( opts . maxAge && ! isNaN ( opts . maxAge ) ) this . header ( 'Access-Control-Max-Age' , ( opts . maxAge / 1000 | 0 ) . toString ( ) ) if ( opts . credentials ) this . header ( 'Access-Control-Allow-Credentials' , opts . credentials . toString ( ) ) if ( opts . exposeHeaders ) this . header ( 'Access-Control-Expose-Headers' , opts . exposeHeaders ) return this }
Convenience method for setting CORS headers
Convenience method for setting CORS headers
// Check for existing headers // Default CORS headers // Optional CORS headers