Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add "devServer.server.type" to "useHttps" judgement #7222

Merged
merged 1 commit into from Jul 7, 2022

Conversation

backrunner
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

Other information:

In the recent merged Pull Request #7202 which authored by me, the fixed judgement expression is not perfect, it should also consider the devServer.server.type because it can be an object.

This patch add another judgement expression to cover this case, if user set devServer.server.type to https or spdy, the protocol will be https.

@sodatea sodatea merged commit 0260e4d into vuejs:dev Jul 7, 2022
1 of 2 checks passed
@jacekkarczmarczyk
Copy link

jacekkarczmarczyk commented Jul 7, 2022

With this fix https for the application seems to work fine, however it fails to connect to HMR server:

module.exports = defineConfig({
  devServer: {
    server: {
      type: 'https',
      options: {
        key: fs.readFileSync('...'),
        cert: fs.readFileSync('...'),
      },
    },
  },

image

iirc the following config worked in vue cli 4/webpack 4

  devServer: {
    https: {
      key: fs.readFileSync('...'),
      cert: fs.readFileSync('...'),
    },
  },

@backrunner
Copy link
Contributor Author

backrunner commented Jul 7, 2022

With this fix https for the application seems to work fine, however it fails to connect to HMR server:

module.exports = defineConfig({
  devServer: {
    server: {
      type: 'https',
      options: {
        key: fs.readFileSync('...'),
        cert: fs.readFileSync('...'),
      },
    },
  },

image

iirc the following config worked in vue cli 4/webpack 4

  devServer: {
    https: {
      key: fs.readFileSync('...'),
      cert: fs.readFileSync('...'),
    },
  },

Your case is similar to #7160, if NODE_ENV is not production, @vue/cli-service always prefer using the lan IP as webSocketURL. I think that might not work properly in some scenarios. You can try to set devServer.client.webSocketURL to auto://localhost:[YOUR_SERVER_PORT]/ws and set devServer.allowedHosts to all if you're running the dev server at local.

@jacekkarczmarczyk
Copy link

Thanks @backrunner
Following config works fine for me

  devServer: {
    server: {
      type: 'https',
      options: {
        key: fs.readFileSync('...'),
        cert: fs.readFileSync('...'),
      },
    },
    client: {
      webSocketURL: 'auto://localhost:8081/ws',
    },
    allowedHosts: 'all',
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants