0.1.1 • Published 6 years ago

ah-cors-plugin v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

ah-cors-plugin

CircleCI

Configure CORS origins for Actionhero v18+


NPM | GitHub


Install & Setup

  1. npm install ah-cors-plugin --save
  2. Register the plugin

    // config/plugins.js
    exports['default'] = {
      plugins: (api) => {
        return {
    +      'ah-cors-plugin': { path: path.join(__dirname, '/../node_modules/ah-cors-plugin') }
        }
      }
    }
  3. Configure the origins or use ALLOWED_ORIGINS environment

    // config/cors.js
    exports[ 'default' ] = {
      cors: () => {
        return {
          // Should the plugin be enabled
          enabled: false,
          // List of origins that are allowed, all the rest will get `null` as `Access-Control-Allow-Origin`
          allowedOrigins: [ 'http://localhost:5000' ] || '*'
        }
      }
    }
    
    exports.production = {
      cors: () => {
        return {
          enabled: true
        }
      }
    }