Fix error when using check_referer=true