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

后端 未结 4 1897
走了就别回头了
走了就别回头了 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 17:42

    Option 1

    If you do not need to use Authentication you can add configs to ngrok commands

    ngrok http 9000 --host-header=rewrite

    or

    ngrok http 9000 --host-header="localhost:9000"

    But in this case Authentication will not work on your website because ngrok rewriting headers and session is not valid for your ngrok domain

    Option 2

    If you are using webpack you can add the following configuration

    devServer: {
        disableHostCheck: true
    }
    

    In that case Authentication header will be valid for your ngrok domain

提交回复
热议问题