-
Notifications
You must be signed in to change notification settings - Fork 413
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
Add option to expose WebpackDevServer publicly for non-localhost development #1621
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1621 +/- ##
=======================================
Coverage 81.04% 81.04%
=======================================
Files 178 178
Lines 11696 11696
Branches 2843 2846 +3
=======================================
Hits 9479 9479
Misses 2013 2013
Partials 204 204 Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1621 +/- ##
=======================================
Coverage 82.05% 82.05%
=======================================
Files 176 176
Lines 11908 11908
Branches 2901 2898 -3
=======================================
Hits 9771 9771
Misses 1949 1949
Partials 188 188 Continue to review full report at Codecov.
|
Some context for my teammates: One issue is how we access the dev server: obviously the server won't be accessible from the docker container as it binds on localhost. gitpod comes with a system to forward ports, but the webpack dev server has a system to checks the Host to prevent security problems. See this posts about this issue:
The PR here disables this check and I'm reluctant to do it. Ideally gitpod should tell you which host will be used, and we could use it when configuring the server. |
Note: This PR only disables the check if you explicitly set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the proposed changes make it safer and still not overengineered :)
Then a user could pass the expected host through PERFHTML_PUBLICHOST
(maybe with a bit of guessing in the case of gitpod - but should be doable) and have it exposed properly.
server.js
Outdated
@@ -13,6 +15,7 @@ const localConfigExists = fs.existsSync( | |||
const serverConfig = { | |||
contentBase: config.output.path, | |||
publicPath: config.output.publicPath, | |||
disableHostCheck: process.env.PERFHTML_PUBLICHOST === 'true', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this and add public: host
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. But is public: host
still needed here? Or maybe host
should be added to allowedHosts
?
} | ||
); | ||
console.log(barAscii); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed it's weird your prettier run changed everything here. Meh :)
@gregtatum I'd like your second opinion on this :) here is how you can try the issue we're facing:
|
I don't think I understand enough about this issue to really weigh in. I did the STR, but I'm not sure what's really going on behind the scenes with the tech. What is even sending out "Invalid Host Header"? |
@gregtatum Thanks for looking into this!
That's WebpackDevServer, because it doesn't accept connections that use domains other than This is essentially why I added support for making |
To me, these are the relevant options to address this:
This PR implements Option 3. @julienw seems to prefer Option 2. |
I don't really have an opinion on this either. I'd even be fine with a gitpod-specific command that looks at the |
That special command could do:
Assuming this |
Interesting idea, thanks! We'll still need to implement
Unfortunately, it is not constant (e.g. if you're in Asia, it will be |
I got 1 thought and 1 remark. First, the thought: after looking at this again, I now think this is probably good enough to do what @janx proposed initially. That we're not having this setup by default is probably good enough for security. I'd still be happier with the other solution though. Especially that the next remark could make it a lot easier: Indeed I noticed that the |
Wow, that's a really cool find! This looks like a much cleaner solution indeed. 😄 |
f163d31
to
e0edc6c
Compare
@julienw Thanks again for your advice! I've implemented non-localhost support without using (Also, I haven't added |
ff5d73a
to
49f2585
Compare
(Rebased on top of latest master.) |
49f2585
to
2cfe7eb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some small suggestions, I hope you'll find them OK :)
@julienw Many thanks! 😄 The suggestions make sense to me, so I've applied them. I'll also rebase the commits now. |
Co-Authored-By: jankeromnes <jan.keromnes@typefox.io>
94f11f8
to
04706a6
Compare
🎉 🎉 🎉 Thanks a lot @julienw! 😄 |
If you'd like to use perf.html via URLs that are not
localhost
(e.g. from behind a proxy, or from another device) I suggest to expose the web application publicly like so: