Skip to content

A Node.js server file that uses the Next.js framework for server-side rendering. This file sets up an HTTPS server, reads SSL certificates, and handles different routes by rendering different pages.

Notifications You must be signed in to change notification settings

fariborz0015/nextjs-ssl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Nest Logo

Next.js HTTPS Server In Local & Development Mode

A Node.js server file that uses the Next.js for run server on a HTTPS protocol in local and devvelopment mode

Get Start

  1. Clone the repository:
git clone https://github.com/fariborz0015/nextjs-ssl.git
  1. Copy files:
  • copy ssl folder and server.js file in to your root project
  1. Modify package.json file script 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.

  1. 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.

Config

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 

Contact

For any questions or inquiries, please reach out to the project maintainer:

MIT License MIT License

Feel free to open an issue on GitHub if you encounter any problems or have suggestions for improvement.

Happy coding! 👨‍💻

Authors

About

A Node.js server file that uses the Next.js framework for server-side rendering. This file sets up an HTTPS server, reads SSL certificates, and handles different routes by rendering different pages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published