[#164] Fix middleware for CNAME access of partner sites

Fix runtime error happening when a partner site is requested using a
CNAME domain