-
Notifications
You must be signed in to change notification settings - Fork 105
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
Changed the web-server from HTTP1 to HTTP2.. #609
base: main
Are you sure you want to change the base?
Conversation
web-server/server.js
Outdated
createServer(httpsOptions, (req, res) => { | ||
const parsedUrl = parse(req.url, true); | ||
handle(req, res, parsedUrl); | ||
}).listen(3333, (err) => { |
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.
Doesn't use the PORT environment variable.
web-server/server.js
Outdated
handle(req, res, parsedUrl); | ||
}).listen(3333, (err) => { | ||
if (err) throw err; | ||
console.log('> Server started on https://localhost:3333'); |
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.
Same as above.
@jayantbh i have made the changes as asked.. kindly review the changes.. i am up for anymore changes and to learn.. :) |
Hey sorry for the delay. We'll check it out in a day or so. |
hey @jayantbh no issues with the delay :-) i waited patiently i saw somehow the code i pushed was having linting error so i fixed it with pre-commit run and it made that yarn lock changes and to re assure i also ran the container and from my side everything is working fine, do check the pr and if possible lets merge this one! |
web-server/package.json
Outdated
@@ -123,7 +123,7 @@ | |||
"eslint-config-next": "13.5.6", | |||
"eslint-plugin-import": "^2.29.0", | |||
"eslint-plugin-prettier": "^5.0.1", | |||
"eslint-plugin-react": "^7.29.4", | |||
"eslint-plugin-react": "^7.37.2", |
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.
Is this change actually needed?
If not, you might be able to reduce the size of your PR significantly.
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.
@not-meet reminder ☝🏽
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.
@jayantbh hi really sorry for the delay ill fix this asap, actually this happened back when the pr was not able to merge because of linting then i used pre-commit to fix the issue and it gave me an error and a command to fix the error and after that when i ran pre-commit this issue happened... ill fix this as soon as possible.. :-)
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.
@jayantbh hi.. i made the eslint-plugin- react changes as they were also ran pre-commit run all files to make sure the linting problem dose not happen again...i hope this will solve all the issues while merging the pr :-)
I checked out the branch to run it locally Nonetheless, I keep getting this error and wasn't able to get it to work even after running the certificates script. Mainly because the script creates certificates w.r.t. the current directory, so running this script anywhere other than the web-server directory will break it. If you hook the certificates generation behaviour to ./dev.sh, you might have some new ways to deal with it.
|
Happy Diwali to you too, @not-meet! ❤️ |
hey @jayantbh i have made changes as you asked but i have one doubt in this... after doing the changes though without changing the type to module everything is working fine on my side :-) |
I think you'd have to change the next.config.js to use import/export instead of require/module.exports and it should work just fine. |
did changes as asked! also did some renames of eslint and next.config to align with type :"module".. also one more thing while running the server it showed one warning of unrecognized file extension i tried experimenting by removing it but after removing it the website crashed so i kept it like it is ! |
Yeah that's okay, that warning has been there since ages but it's never really caused any real issues... or any issues as far as we could tell. |
hey @jayantbh so as i fixed the linting issue all the checks have passed and i believe the pr is somewhere close to get merge too !! so if there are any more tweaks you want in the pr i'll be more than happy to do them... :-) |
Hey @not-meet, I see that it works ok for dev mode, Also, in prod mode there is no mechanism to generate the certificate. I think if you make the certificate generation be part of the server.js script, so it creates one right on server boot, it might work. But I also see that there's no mechanism to refresh the certificate either. |
I recommend making a checklist of functionality that this PR needs to have so you can ensure nothing gets missed. |
@jayantbh apologies for that... ill fix all the issues as fast as i can... also will make a checklist of functionality that PR need as well <3 |
Hi @jayantbh , First of all, apologies for being inactive for the past 2-3 days, as I was unwell. I’ve made some progress with the requirements and researched how to best implement them. Currently, on the dev server, server.js calls the generate certificate script itself. I also made the following changes to the script: The script now generates a private key and a self-signed root certificate. https://surma.dev/things/h2setup/ I discovered that the "Not Secure" warning in dev appears because the certificates aren’t added to the local Certificate Authority. I found a solution using "mkcert" to create a CA, but it requires installation on the local machine. I assume some adjustments in Docker to initialize the CA at runtime,may help resolve this issue. also, For the production setup: I know this PR is taking longer than expected, and I’m aware that some of my rookie mistakes have caused delays. I’ll make sure to wrap this up as soon as possible, with just a bit of guidance. Thank you for your patience! <3 |
ab5b221
to
0d577b8
Compare
I think you're making good progress! |
…or a hard coded 3333
* fix: updated Next to 14.2.16 * fix: updated Next to 15.0.1 * fix: pre-commit hook update for eslint-config-next * fix: pre-commit hook update for eslint-config-next * fix: pre-commit hook update for eslint-plugin-react, eslint-plugin-unused-imports
605749d
to
40a7221
Compare
Hi @jayantbh !! so i did the changes in the dev server as asked now the certificates are generated when the docker files runs plus a CA is also estabilished for the ssl certificates.. What i did ? i tested it by generating certificates locally and for me it worked....! Note- currently i am facing a problem with the dev server which is.. that the browser still shows not secure even after adding a CA and verifying the certificates..! |
I think that's only because you can't verifiably sign certificates, even self-signed with the localhost domain. Maybe signing it as www.localhost will work? Of course, you'll need to then load the webserver on www.localhost, which should be trivial. Give that a shot? |
Linked Issue(s)
#598
Acceptance Criteria fulfillment
reference taken from -> https://medium.com/@greg.farrow1/nextjs-https-for-a-local-dev-server-98bb441eabd7
Further comments
Comment
This pull request includes several changes to improve the security and modularity of the web server setup, along with some other minor updates. The most important changes include switching to HTTPS for local development, converting the configuration file to use ES modules, and adding a script to generate SSL certificates.
Security improvements:
cli/source/app.tsx
: Changed the local development URL from HTTP to HTTPS.Modularity and configuration updates:
web-server/next.config.mjs
: Renamed fromnext.config.js
and converted the configuration to use ES modules. [1] [2]web-server/package.json
: Added"type": "module"
to support ES modules and updated thedev
andstart
scripts to useserver.js
.Automated SSL certificate generation:
web-server/scripts/generate-certificates.sh
: Added a script to generate SSL certificates for local development.web-server/server.js
: Added a new server setup to use HTTPS with the generated SSL certificates.