I think you should be checking here for this.env.conf.wiki.apiURI and not just "api.php" - this is because for instance call to outside world MediaWiki installation (such as Wikipedia) would contain api.php as well.