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

v4.0.0-beta.0 and host option #2874

Closed
1 of 2 tasks
dartess opened this issue Nov 28, 2020 · 8 comments · Fixed by #2892 or #3115
Closed
1 of 2 tasks

v4.0.0-beta.0 and host option #2874

dartess opened this issue Nov 28, 2020 · 8 comments · Fixed by #2892 or #3115

Comments

@dartess
Copy link

dartess commented Nov 28, 2020

  • Operating System: macOS 11.0.1
  • Node Version: v14.15.1
  • NPM Version: 6.14.8
  • webpack Version: 5.8.0
  • webpack-dev-server Version: 4.0.0-beta.0
  • Browser: Chrome last
  • This is a bug
  • This is a modification request

Question

How should I replace the host option in the new version?
Perhaps I did not understand this from the changelog.

webpack-dev-server v3:

devServer: {
  host: 'some.site.loc',
  <...>
}

with webpack-dev-server v4 I try:

devServer: {
  client: {
    host: 'some.site.loc',
  }
  <...>
}

Result from console:

<i> [webpack-dev-server] Project is running at https://127.0.0.1:9090/

When I try open https://some.site.loc:9090 I get response Invalid Host header.

If I do not change the option (I leave it as it was in the previous version), then by default https://127.0.0.1:9090 will still open, but https:/some.site.loc:9090 also works. In this case, I would like the console to write the correct address and the correct address to open in the browser.

@alexander-akait
Copy link
Member

alexander-akait commented Nov 28, 2020

devServer: {
  host: 'some.site.loc',
}

Nothing changed for host

client.host for websocket server, in 99% cases you should not touch this

@dartess
Copy link
Author

dartess commented Nov 28, 2020

Okay, thanks

Full config:

    devServer: {
        host: 'some.site.loc',
        https: {
            key: fs.readFileSync(path.join('docker', 'ssl', 'some.site.loc-key.pem')),
            cert: fs.readFileSync(path.join('docker', 'ssl', 'some.site.loc.pem')),
            ca: fs.readFileSync(path.join('docker', 'ssl', 'rootCA.pem')),
        },
        port: 9090,
        static: path.resolve(appDir, 'public'),
        open: true,
        historyApiFallback: {
            rewrites: [
                {
                    from: /./,
                    to: '/build/index.html'
                },
            ],
        },
        proxy: {
            '/api': `http://${hostLocal}`,
        },
    },

Console output:

<i> [webpack-dev-server] Project is running at https://127.0.0.1:9090/

browser open:

https://127.0.0.1:9090/

https://some.site.loc:9090/ also works.

The only problem is false output to the console and the opened address in the browser.

@alexander-akait
Copy link
Member

Yep, bug, try to fix it in near future

@dartess
Copy link
Author

dartess commented Mar 24, 2021

@alexander-akait
i tried updating to 4.0.0-beta.1
still doesn't work as it should :(

from config:

{
    devServer: {
        host: 'some.site.loc'
    }
}

Console output:

<i> [webpack-dev-server] Project is running at https://localhost:9090/, https://127.0.0.1:9090/ (IPv4)

browser open:

https://localhost:9090/

But I would like to get https://some.site.loc:9090/ in browser on startup. This address also works, but I need to open it manually.

@alexander-akait
Copy link
Member

some.site.loc is localhost?

@dartess
Copy link
Author

dartess commented Mar 24, 2021

um yeah

from my hosts:

127.0.0.1       some.site.loc

@alexander-akait
Copy link
Member

You can use openPage: 'some.site.loc'

@dartess
Copy link
Author

dartess commented Mar 24, 2021

thanks, I didn't know about this option

with openPage: 'some.site.loc' i get https://localhost:9090/some.site.loc

I used https://${host}:${port}, it works but looks weird :)

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