A Node.js
server file that uses the Next.js
for run server on a HTTPS
protocol in local and devvelopment mode
- Clone the repository:
git clone https://github.com/fariborz0015/nextjs-ssl.git
- Copy files:
- copy
ssl
folder andserver.js
file in to your root project
- Modify
package.json
filescript
section like this :
from this :
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
to this :
"scripts": {
"dev": "next dev",
"dev:ssl":"node server", // add this line
"build": "next build",
"start": "next start",
"lint": "next lint"
},
then run :
npm rundev:ssl
This will start the HTTPS server on the specified port and hostname.
- Alternative way to
step 3
:
you can without change the package.js
run this cli
command:
node server.js
This will start the HTTPS server on the specified port and hostname.
To Config the server runner you can change this variables in server.js
:
const { createServer } = require("https");
const { parse } = require("url");
const next = require("next");
const { readFileSync } = require("fs");
const dev = process.env.NODE_ENV !== "production";
const hostname = "localhost"; // host name
const port = 20000; // your wanted port
For any questions or inquiries, please reach out to the project maintainer:
Feel free to open an issue on GitHub if you encounter any problems or have suggestions for improvement.
Happy coding! 👨💻