<p dir="auto">This can be done in nodejs.</p>
<p dir="auto">This is not possible in deno.</p>
<div class="highlight highlight-source-ts notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import { serve } from &quot;https://deno.land/std@0.144.0/http/mod.ts&quot;;
import { assertEquals } from &quot;https://deno.land/std@0.144.0/testing/asserts.ts&quot;;


Deno.test(&quot;websocket-host&quot;, async () =&gt; {
    const ac = new AbortController();
    const { signal } = ac;
    const p = serve(
        function (req) {
            console.log(&quot;request&quot;, req);
            const { socket, response } = Deno.upgradeWebSocket(req);

            socket.addEventListener(&quot;open&quot;, () =&gt; {
                socket.send(req.url);
                socket.close();
            });

            return response;
        },
        {
            signal,
            port: 5000,
        }
    );
    const socket = new WebSocketStream(&quot;ws://127.0.0.1:5000/&quot;, {
        headers: { host: &quot;localhost.hello.world:9900&quot; },
    });
    const connection = await socket.connection;
    const reader = connection.readable.getReader();
    let text = &quot;&quot;;

    while (true) {
        const result = await reader.read();
        if (result.done) {
            break;
        } else {
            text = text + result.value;
        }
    }
    assertEquals(text, &quot;http://localhost.hello.world:9900/&quot;);
    ac.abort();
    await p;
});
"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">serve</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://deno.land/std@0.144.0/http/mod.ts"</span><span class="pl-kos">;</span>
<span class="pl-k">import</span> <span class="pl-kos">{</span> <span class="pl-s1">assertEquals</span> <span class="pl-kos">}</span> <span class="pl-k">from</span> <span class="pl-s">"https://deno.land/std@0.144.0/testing/asserts.ts"</span><span class="pl-kos">;</span>


<span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">test</span><span class="pl-kos">(</span><span class="pl-s">"websocket-host"</span><span class="pl-kos">,</span> <span class="pl-k">async</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">const</span> <span class="pl-s1">ac</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-smi">AbortController</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-kos">{</span> signal <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-s1">ac</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">p</span> <span class="pl-c1">=</span> <span class="pl-en">serve</span><span class="pl-kos">(</span>
        <span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-smi">console</span><span class="pl-kos">.</span><span class="pl-en">log</span><span class="pl-kos">(</span><span class="pl-s">"request"</span><span class="pl-kos">,</span> <span class="pl-s1">req</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-k">const</span> <span class="pl-kos">{</span> socket<span class="pl-kos">,</span> response <span class="pl-kos">}</span> <span class="pl-c1">=</span> <span class="pl-smi">Deno</span><span class="pl-kos">.</span><span class="pl-en">upgradeWebSocket</span><span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-s1">socket</span><span class="pl-kos">.</span><span class="pl-en">addEventListener</span><span class="pl-kos">(</span><span class="pl-s">"open"</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
                <span class="pl-s1">socket</span><span class="pl-kos">.</span><span class="pl-en">send</span><span class="pl-kos">(</span><span class="pl-s1">req</span><span class="pl-kos">.</span><span class="pl-c1">url</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
                <span class="pl-s1">socket</span><span class="pl-kos">.</span><span class="pl-en">close</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
            <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

            <span class="pl-k">return</span> <span class="pl-s1">response</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-kos">{</span>
            signal<span class="pl-kos">,</span>
            <span class="pl-c1">port</span>: <span class="pl-c1">5000</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">socket</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-smi">WebSocketStream</span><span class="pl-kos">(</span><span class="pl-s">"ws://127.0.0.1:5000/"</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
        <span class="pl-c1">headers</span>: <span class="pl-kos">{</span> <span class="pl-c1">host</span>: <span class="pl-s">"localhost.hello.world:9900"</span> <span class="pl-kos">}</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">connection</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">socket</span><span class="pl-kos">.</span><span class="pl-c1">connection</span><span class="pl-kos">;</span>
    <span class="pl-k">const</span> <span class="pl-s1">reader</span> <span class="pl-c1">=</span> <span class="pl-s1">connection</span><span class="pl-kos">.</span><span class="pl-c1">readable</span><span class="pl-kos">.</span><span class="pl-en">getReader</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> <span class="pl-s1">text</span> <span class="pl-c1">=</span> <span class="pl-s">""</span><span class="pl-kos">;</span>

    <span class="pl-k">while</span> <span class="pl-kos">(</span><span class="pl-c1">true</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        <span class="pl-k">const</span> <span class="pl-s1">result</span> <span class="pl-c1">=</span> <span class="pl-k">await</span> <span class="pl-s1">reader</span><span class="pl-kos">.</span><span class="pl-en">read</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">if</span> <span class="pl-kos">(</span><span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-c1">done</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            <span class="pl-k">break</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span> <span class="pl-k">else</span> <span class="pl-kos">{</span>
            <span class="pl-s1">text</span> <span class="pl-c1">=</span> <span class="pl-s1">text</span> <span class="pl-c1">+</span> <span class="pl-s1">result</span><span class="pl-kos">.</span><span class="pl-c1">value</span><span class="pl-kos">;</span>
        <span class="pl-kos">}</span>
    <span class="pl-kos">}</span>
    <span class="pl-en">assertEquals</span><span class="pl-kos">(</span><span class="pl-s1">text</span><span class="pl-kos">,</span> <span class="pl-s">"http://localhost.hello.world:9900/"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-s1">ac</span><span class="pl-kos">.</span><span class="pl-en">abort</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">await</span> <span class="pl-s1">p</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="websocket-host =&gt; ./test.ts:26:6
error: AssertionError: Values are not equal:


    [Diff] Actual / Expected


-   http://127.0.0.1:5000/
+   http://localhost.hello.world:9900/


  throw new AssertionError(message);
        ^
    at assertEquals (https://deno.land/std@0.144.0/testing/asserts.ts:176:9)
    at file:///C:/Documents/test/test.ts:62:5

 FAILURES


websocket-host =&gt; ./test.ts:26:6"><pre class="notranslate"><code class="notranslate">websocket-host =&gt; ./test.ts:26:6
error: AssertionError: Values are not equal:


    [Diff] Actual / Expected


-   http://127.0.0.1:5000/
+   http://localhost.hello.world:9900/


  throw new AssertionError(message);
        ^
    at assertEquals (https://deno.land/std@0.144.0/testing/asserts.ts:176:9)
    at file:///C:/Documents/test/test.ts:62:5

 FAILURES


websocket-host =&gt; ./test.ts:26:6
</code></pre></div>
<p dir="auto">The current version of deno seems to read <code class="notranslate">deno.json</code> from the current directory by default without <code class="notranslate">--config</code> parameter specified. This default is certainly convenient, but if there is a special case where I need to run deno <strong>without config</strong> when there is <code class="notranslate">deno.json</code> in the current directory, how should I do it? If there is no way to do this, is it considered to add an option or some way to achieve it?</p>