Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins Rails.configuration.spa_origin_url

    resource '/api/*',
      headers: :any,
      methods: [:get, :post, :put, :delete, :options],
      credentials: true
  end

  allow do
    origins Rails.configuration.spa_origin_url

    resource '/jamtracks/*',
      headers: :any,
      methods: [:get],
      credentials: true
  end

  allow do
    origins Rails.configuration.spa_origin_url

    resource '/unsubscribe/*',
      headers: :any,
      methods: [:get, :post, :put, :delete, :options],
      credentials: true
  end

  allow do
    origins Rails.configuration.spa_origin_url

    resource '/video/room/*',
      headers: :any,
      methods: [:get],
      credentials: true
  end
  
end