如何将公共ip上的angular应用连接到本地服务器上的node应用?

时间:2018-07-11 07:48:26

标签: node.js angular npm ip httpservice

我有一个angular 4和一个节点应用程序。我将它们与HTTP服务连接。现在,我将它们放在IP地址为192.168.x.y的本地服务器上。我通过以下方式启动我的角度应用程序:<form action=""> <div> <input type="radio" name="poke-name" class="ButtonState" id="Ash" value="-1" /> <label class="Button" for="Ash">Ash</label> <input type="radio" name="poke-name" class="ButtonState" id="Misty" value="-2" /> <label class="Button" for="Misty">Misty</label> <input type="radio" name="poke-name" class="ButtonState" id="Brock" value="-3" /> <label class="Button" for="Brock">Brock</label> <input type="radio" name="poke-name" class="ButtonState" checked id="Oak" value="-4" /> <label class="Button" for="Oak">Oak</label> <input type="radio" name="poke-name" class="ButtonState" id="Jessie" value="-5" /> <label class="Button" for="Jessie">Jessie</label> <input type="radio" name="poke-name" class="ButtonState" id="James" value="-6" /> <label class="Button" for="James">James</label> <input type="radio" name="poke-name" class="ButtonState" id="Giovanni" value="-7" /> <label class="Button" for="Giovanni">Giovanni</label> </div> <br> <br> <div> <input type="radio" name="poke-type" class="ButtonState" id="Pickachu" value="1" /> <label class="Button" for="Pickachu">Pickachu</label> <input type="radio" name="poke-type" class="ButtonState" checked id="Bulbasaur" value="2" /> <label class="Button" for="Bulbasaur">Bulbasaur</label> <input type="radio" name="poke-type" class="ButtonState" id="Charmander" value="3" /> <label class="Button" for="Charmander">Charmander</label><input type="radio" name="poke-type" class="ButtonState" id="Squirtle" value="4" /> <label class="Button" for="Squirtle">Squirtle</label><input type="radio" name="poke-type" class="ButtonState" id="Butterfree" value="5" /> <label class="Button" for="Butterfree">Butterfree</label><input type="radio" name="poke-type" class="ButtonState" id="Pidgeotto" value="6" /> <label class="Button" for="Pidgeotto">Pidgeotto</label><input type="radio" name="poke-type" class="ButtonState" id="Arbok" value="7" /> <label class="Button" for="Arbok">Arbok</label><input type="radio" name="poke-type" class="ButtonState" id="Sandshrew" value="8" /> <label class="Button" for="Sandshrew">Sandshrew</label><input type="radio" name="poke-type" class="ButtonState" id="Jigglypuff" value="9" /> <label class="Button" for="Jigglypuff">Jigglypuff</label><input type="radio" name="poke-type" class="ButtonState" id="Vulpix" value="10" /> <label class="Button" for="Vulpix">Vulpix</label> </div> <br> <input type="button" value="Go" onclick="myfunction()" /> </form>,其中151.233.t.z是我的公共IP。最后,我通过以下方式运行我的应用: ng serve --port 8080 --host 192.168.x.y --public 151.233.t.zpm2 start npm -- start(我的节点服务器正在侦听端口3000),然后在HTTP服务中,我将HTTP请求发送到{ {1}}。当我在本地系统上的151.233.t.z:8080上打开浏览器时,一切正常。但是当我在网络外部尝试时,我只能看到我的角度应用程序,并且当我单击按钮发送登录请求后,它就无法正常工作!

0 个答案:

没有答案