Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Webhook Engine does not provide the /debug route as expected #49

Closed
reidcooper opened this issue Jul 10, 2018 · 1 comment
Closed

Webhook Engine does not provide the /debug route as expected #49

reidcooper opened this issue Jul 10, 2018 · 1 comment

Comments

@reidcooper
Copy link
Contributor

reidcooper commented Jul 10, 2018

Upon mounting the engine, I am unable to access the /webhooks/debug route.

My suggested fix in contentful_rails/development_constraint.rb:

module ContentfulRails
  # Constraint for ensuring development origin
  class DevelopmentConstraint
    # Returns if current request is coming from development environment or localhost
    def self.matches?(request)
      Rails.env =~ %r{development} && (request.remote_ip =~ %r{127.0.0} || request.remote_ip =~ %r{^::1$})
    end
  end
end

Due to https://stackoverflow.com/a/12384762/3674071 stating that the %r{} syntax allows you to use / without having to escape them. We don't want to check whether or not the Rails.env = "/development/", but if its "development". Applies concept to the request.remote_ip assertions as well.

@dlitvakb
Copy link
Contributor

Thanks for the fix, just merged.

Cheers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants