Invalid Host Header when ngrok tries to connect to React dev server

后端 未结 4 1890
走了就别回头了
走了就别回头了 2021-01-29 17:04

I\'m trying to test my React application on a mobile device. I\'m using ngrok to make my local server available to other devices and have gotten this working with a variety of o

4条回答
  •  孤街浪徒
    2021-01-29 18:00

    I'm encountering a similar issue and found two solutions that work as far as viewing the application directly in a browser

    ngrok http 8080 -host-header="localhost:8080"
    ngrok http --host-header=rewrite 8080
    

    obviously replace 8080 with whatever port you're running on

    this solution still raises an error when I use this in an embedded page, that pulls the bundle.js from the react app. I think since it rewrites the header to localhost, when this is embedded, it's looking to localhost, which the app is no longer running on

提交回复
热议问题