How to conver PHP foreach to JavaScript

I have the following php (old application) and I want to recreate a robots.txt for a Nuxt Application in in valid JS:

//Disallow all for container domains /
$is_container = false;
$containers = array('url.one','url.two');
foreach($containers as $container) {
    if(strpos($_SERVER['HTTP_HOST'], $container) !== false) {
        $is_container = true;
    }
}

if($is_container) {
?>
User-agent: *
Disallow: /

<?php
exit;
}

in my Nuxt.config I have this option:

// doSomthing: Is where I want to create the conditional logic above

  robots: (doSomething) => {
    return {
      UserAgent: '*',
      Disallow: '/',
    }
  },

Please could you help me in the right direction?