Skip to content

Commit

Permalink
Update server.js to protocol based on hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
emielwit committed Nov 20, 2023
1 parent b513ea3 commit d44b347
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 d44b347

Please sign in to comment.