Skip to content

Commit

Permalink
Merge pull request #169 from bettyblocks/log-protocol-and-host
Browse files Browse the repository at this point in the history
Update server.js to protocol based on hostname
  • Loading branch information
emielwit authored Nov 20, 2023
2 parents 5cac6c1 + d44b347 commit 6ca581e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ const serve = (request, response, file) => {
response.status(500).send("Internal Error: " + error.code + " ..\n");
}
} else {
const hostname = `${request.protocol}://${request.headers.host}`;
console.log({ protocol: request.protocol, host: request.headers.host });
const protocol = request.headers.host.includes("localhost")
? request.protocol
: "https";

const hostname = `${protocol}://${request.headers.host}`;
console.log({ protocol: protocol, host: request.headers.host });
const json = content
.toString()
.replaceAll(HOST, hostname)
Expand Down

0 comments on commit 6ca581e

Please sign in to comment.