【问题标题】:Exposing the localhost to the world always gives 5** [ngrok, localtunnel, etc]将 localhost 暴露给世界总是给出 5** [ngrok, localtunnel, etc]
【发布时间】:2021-01-26 17:59:09
【问题描述】:

我有一个使用以下命令从本地服务器启动的 React JS 应用程序:react-scripts start:

Compiled successfully!

You can now view telco-widget in the browser.

  Local:            http://localhost:3000/
  On Your Network:  http://192.168.0.117:3000/

Note that the development build is not optimized.
To create a production build, use yarn build.

我想向世界公开本地主机,所以我尝试了ngrok

ngrok http 3000

给出有效输出:

Session Status                online                                                                                                        
Account                       xxx (Plan: Free)                                                                                              
Version                       2.3.35                                                                                                        
Region                        Europe (eu)                                                                                                   
Web Interface                 http://127.0.0.1:4040                                                                                         
Forwarding                    http://xxx.eu.ngrok.io -> http://localhost:3000                                                      
Forwarding                    https://xxx.eu.ngrok.io -> http://localhost:3000                                                     
                                                                                                                                            
Connections                   ttl     opn     rt1     rt5     p50     p90                                                                   
                              0       0       0.00    0.00    0.00    0.00 

但是一旦我尝试访问https://xxx.eu.ngrok.io,我就会看到一个错误:

我也试过了:

  • ngrok 替代品如 localtunnel 但结果相似:504 错误
  • 更改网络服务器的端口
  • 使用 ngrok(运行良好:ngrok http file:///Users/me/share)而不是 localhost 为本地目录提供服务
  • 使用干净的etc/hosts

工具的版本:

  • 反应脚本 - 3.1.2
  • 纱线 - 1.22.4
  • ngrok - 2.3.35
  • localtunnel - 2.0.0

【问题讨论】:

    标签: localhost webserver ngrok tunnel localtunnel


    【解决方案1】:

    老兄!您的网络服务器没有运行。

    确保您的服务器正在运行并尝试在浏览器中打开链接 localhost:3000。 如果您还有任何问题,请告诉我。

    【讨论】:

    • 感谢您的回复。服务器正在运行。我可以打开 localhost:3000 并看到渲染的全功能反应应用程序。结果与本地网络 IP 相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多