Skip to content

Commit

Permalink
Rename domain to host
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikElfstrom committed Sep 8, 2021
1 parent e08fa71 commit 7c68a5a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ serve ~/myproj
- `sudo` may be necessary.
- If a static path is not provided the current directory content will be served.
- You can change the **port** setting the `PORT` environmental variable: `PORT=4433 serve ~/myproj`. Specifying port number will also prevent http to https redirect.
- You can change the **domain** setting the `DOMAIN` environmental variable: `DOMAIN=192.168.0.2 serve ~/myproj`.
- You can change the **host** setting the `HOST` environmental variable: `HOST=example.com serve ~/myproj`.

### Binaries
If you don't have Node.js installed just use a packaged version! Download it from the [release page](https://github.com/daquinoaldo/https-localhost/releases).
Expand Down
2 changes: 1 addition & 1 deletion certs.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async function generate(appDataPath = CERT_PATH, customDomain = undefined) {
}

async function getCerts(customDomain = undefined) {
const domain = process.env.DOMAIN || customDomain || "localhost"
const domain = process.env.HOST || customDomain || "localhost"
const certPath = process.env.CERT_PATH || CERT_PATH
// check for updates if running as executable
/* istanbul ignore if: cannot test pkg */
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const getCerts = require(path.resolve(__dirname, "certs.js")).getCerts
/* CONFIGURE THE SERVER */

// SSL certificate
const createServer = (domain = process.env.DOMAIN || "localhost") => {
const createServer = (domain = process.env.HOST || "localhost") => {
// create a server with express
const app = express()

Expand Down
4 changes: 2 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe("Testing certs", function() {
it("works with environment domain", function(done) {
(async() => {
// set the environment domain
process.env.DOMAIN = "192.168.0.1"
process.env.HOST = "192.168.0.1"

// Get the cert
const appCerts = await app.getCerts()
Expand All @@ -172,7 +172,7 @@ describe("Testing certs", function() {
const certDomain = cert.subjectaltname.split(":")[1]

// Compare the domains
assert(certDomain === process.env.DOMAIN)
assert(certDomain === process.env.HOST)

done()
})()
Expand Down

0 comments on commit 7c68a5a

Please sign in to comment.