vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

How to use HTTP Basic Auth on dev server? #2970

Open Sociopacific opened 6 years ago

Sociopacific commented 6 years ago

What problem does this feature solve?

When using vue-cli 2, I could proxy dev server through nginx and use HTTP Basic Auth. In vue-cli 3, I cannot configure proxying through nginx, since hot reload stops working (error: GET GET http://localhost:1111/sockjs-node/info?t=1542390765166 net::ERR_CONNECTION_REFUSED, when requesting sockjs it is used internal host, not the one provided by nginx). How can I configure HTTP Basic Auth?

What does the proposed API look like?

The possibility of proxying through nginx without hot reload error

LinusBorg commented 6 years ago

when requesting sockjs it is used internal host, not the one provided by nginx

you can set the dev-server's public option for this. Also try using a baseUrl with the right host&port:


  baseUrl: 'http://yourhost:yourport',
  devServer: {
    public: 'http://yourhost:yourport'
  }
}
Sociopacific commented 6 years ago

when requesting sockjs it is used internal host, not the one provided by nginx

you can set the dev-server's public option for this. Also try using a baseUrl with the right host&port:

  baseUrl: 'http://yourhost:yourport',
  devServer: {
    public: 'http://yourhost:yourport'
  }
}

I do not understand how to use these parameters to properly configure proxying through nginx. I've tried every possible combination.