Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, I finally got it to work somehow. But frankly, I don't get it. It was definitely related to <code>localhost</code> not being the same as <code>127.0.0.1</code>. How did it ended that way, I don't have a clue...</p> <p>I'll share what I learned while doing this, as I found no real answer for debugging this staff out there on the web. Here is what I learned:</p> <ul> <li>grunt has a <code>--verbose</code> option that may help you see what's going on</li> </ul> <p>If grunt-connect-proxy is configured correctly you must see something like this at startup:</p> <pre> Running "configureProxies" task Proxy created for: /api/v1 to localhost:8000 </pre> <p>In my case, the grunt server was running on <code>127.0.0.1:9000</code>, the second server on <code>localhost:8000</code>. I proxied requests made on <code>api/v1</code> so <code>grunt server --verbose</code> would output something like this on every proxied request:</p> <pre><code>Proxied request: /api/v1/test -&gt; http://localhost:8000/api/v1/test { "host": "127.0.0.1:9000", "connection": "keep-alive", "accept": "...", "user-agent": "...", "accept-encoding": "...", "accept-language": "...", "cookie": "..." } </code></pre> <ul> <li>the whole point of using a proxy is to avoid any unnecessary CORS configuration on your second server</li> </ul> <p>This is because once deployed your frontend and backend code will coexist on the same server (= the grunt server is only needed at dev time). I wanted to stress that point, because @Ulugbek answer may suggest that you need CORS to make grunt-connect-proxy work.</p> <ul> <li>the ECONNREFUSED error happens when your second server is not responding</li> </ul> <p>In my case, I discovered that <code>http://127.0.0.1:8000/api/v1/test</code> was not responding even if <code>http://localhost:8000/api/v1/test</code> was. So, I messed around with the /etc/hosts a bit and solved the problem by making sure both endpoints were responding accordingly.</p> <p>The same error may happen to you if the second server is not listening to the proxied endpoint.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload