title: Cypress stubbing seems to yield response from actual server
body: <p>Trying out Cypress in an existing project, I am having problems with stubbing responses for routes. The concept is explained in this documentation article: <a href="https://docs.cypress.io/api/commands/route.html#Without-Stubbing" rel="nofollow noreferrer">https://docs.cypress.io/api/commands/route.html#Without-Stubbing</a>. </p>
  
  <p>Here is a minimal non-working example. I am trying to get an empty object as the response body: </p>
  
  <pre class="lang-js prettyprint-override"><code>describe('The new event page', () =&gt; {
  
    it('responds with the stub', () =&gt; {
      cy.server();
      cy.route('/dummypath', {});
      cy.request('GET', '/dummypath');
    });
  
  });
  </code></pre>
  
  <p>The stubbed route clearly shows up in the GUI:</p>
  
  <p><a href="https://i.stack.imgur.com/QmfDX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QmfDX.png" alt="Picture showing the routes registered in the Cypress GUI"></a></p>
  
  <p>But the response is a 404:</p>
  
  <p><a href="https://i.stack.imgur.com/jPOPs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jPOPs.png" alt="Server responds with a 404"></a></p>
  
  <p>... with the following body:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Error&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;pre&gt;Cannot GET /dummypath&lt;/pre&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I think the 404 response is sent by my actual server instead of the cy.server(). The actual server is running on <code>localhost:3000</code>, which I have specified as the <code>baseUrl</code> in my: <code>cypress.json</code>-file. </p>
  
  <p>Has anyone seen anything similar? Have I overlooked any obvious errors in my code?</p>
  
  <p><strong>PS:</strong>
  When I change the port number to some other, unused port, the error changes to a network error (this should perhaps be expected). </p>
  
  <pre><code> CypressError: cy.request() failed trying to load:
  
  http://localhost:3002/dummypath
  
  We attempted to make an http request to this URL but the request failed without a response.
  
  We received this error at the network level:
  
    &gt; Error: connect ECONNREFUSED 127.0.0.1:3002
  
  -----------------------------------------------------------
  
  The request we sent was:
  
  Method: GET
  URL: http://localhost:3002/dummypath
  
  -----------------------------------------------------------
  
  Common situations why this would fail:
    - you don't have internet access
    - you forgot to run / boot your web server
    - your web server isn't accessible
    - you have weird network configuration settings on your computer
  </code></pre>