-
Notifications
You must be signed in to change notification settings - Fork 126
Setting up Routing Constraints
Tim Fischbach edited this page Dec 9, 2015
·
6 revisions
Available as of Pageflow version 0.2.0.
When there are different CNAMES pointing to your Pageflow installation, you can restrict access to the admin interface to a single host name. That way entries can be published under different URLs while the admin interface is only available under the official domain.
Define a routing constraint:
class HostConstraint
def matches?(request)
request.host == 'pageflow.example.com'
end
end
For the active admin routes, you have to apply the constraint manually in your config/routes.rb
:
PageflowExample::Application.routes.draw do
constraints HostConstraint.new do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
Pageflow.routes(self)
end
Finally, in the Pageflow initializer, activate the constraint for the editor routes defined by Pageflow:
config.editor_route_constraint = HostConstraint.new
Note: Pageflow will use the redirect URL of themings with matching CNAME or display a 404 page for requests outside the route constraint.