From 3ff3135d348e481a47d9988af5157f1775864bae Mon Sep 17 00:00:00 2001 From: Markus Kahl Date: Fri, 30 May 2014 10:33:57 +0100 Subject: [PATCH] map subdirectory unless Passenger is used --- config.ru | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/config.ru b/config.ru index 450de73c031..ebd0d64fbba 100644 --- a/config.ru +++ b/config.ru @@ -30,6 +30,19 @@ # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -use Rack::Protection::JsonCsrf -use Rack::Protection::FrameOptions -run OpenProject::Application + +## +# Returns true if the application should be run under a subdirectory. +def map_subdir? + # Don't map subdir when using Passenger as passenger takes care of that. + !defined?(::PhusionPassenger) +end + +subdir = map_subdir? && OpenProject::Configuration.rails_relative_url_root.presence + +map (subdir || '/') do + use Rack::Protection::JsonCsrf + use Rack::Protection::FrameOptions + + run OpenProject::Application +end