mercredi 24 octobre 2018

Redirection Issue while using https + Rails 3.0.10

Look for any help much appreciated..

I am using this Rails 3.0.10 application hosted on Heroku, which recently added ssl. And my Api::BaseController < ApplicationController looks something like this.

alias_method :original_inherited, :inherited

def inherited(subclass)
  original_inherited(subclass)

  load File.join("#{Rails.root}", "app", "controllers",
                 "api", "#{extract_filename(subclass)}")

  subclass.action_methods.each do |method|
    regex = Regexp.new("^(.*)_(\\d+)$")
    if match = regex.match(method)
      key = "#{subclass.to_s}##{match[1]}"
      @@versions[match[2].to_i] = true
      @@registered_methods[key] ||= {}
      @@registered_methods[key][match[2].to_i] = true

      subclass.instance_eval do
        define_method(match[1].to_sym) {}
      end
    end
  end
  subclass.reset_action_methods
end

def extract_filename(subclass)
  classname = subclass.to_s.split('::')[1]
  parts = classname.underscore.split('_')
  "#{parts.reject{|c| c == 'controller'}.join('_')}_controller.rb"
end

def reset_action_methods
  @action_methods = nil
  action_methods
end

When I make any request it comes here and in some APIs it makes redirection calls like this.

Status : 302 Found
Location : http://3a235934.ngrok.io/en/api/v2/vouchers/show_voucher?auth_token=SxSkyf4GykApgzhSyvWI&id=693

then gives response

Status Code: 200 OK
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 82
Content-Type: application/json; charset=utf-8
Date: Thu, 25 Oct 2018 06:32:44 GMT
Etag: "92234fded00f59326ca858b732179de3"
Server: WEBrick/1.3.1 (Ruby/2.2.10/2018-03-28)
X-Runtime: 5.448165
X-Ua-Compatible: IE=Edge,chrome=1

Aucun commentaire:

Enregistrer un commentaire