Skip to content

Commit fd1d5f0

Browse files
authored
simplify new URL() to use localhost as host as we only check pathname (#3265)
1 parent abbed64 commit fd1d5f0

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

preview/preview.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,8 @@ const checkRedirects = async (core, path) => {
188188

189189
module.exports = Core => {
190190
const server = http.createServer((request, response) => {
191-
let host = process.env.HOST;
192-
if (host == null || host === "") {
193-
host = "localhost";
194-
}
195-
196-
const parsedUrl = new URL(`http://${host}${request.url}`);
191+
//hardcode to 'localhost' only pathname is checked on parsedUrl
192+
const parsedUrl = new URL(`http://localhost${request.url}`);
197193
const prefix = hostPrefix(request.headers['host']);
198194
const core = Core(prefix);
199195
requestHandler(core, parsedUrl, response)

0 commit comments

Comments
 (0)