Skip to content

Commit

Permalink
Merge pull request #3 from therealsujitk/therealsujitk-patch-1
Browse files Browse the repository at this point in the history
Request HTTPS before HTTP
  • Loading branch information
therealsujitk authored Jun 7, 2021
2 parents 7d2c7f7 + 064041b commit 80fca42
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,18 @@ app.get('/*', (req, res) => {
}

try {
http.get("http://" + url, (response) => {
https.get("https://" + url, (response) => {
var statusCode = response.statusCode;

// 308 -> Permanent Redirect
// This could mean HTTP is being redirected to HTTPS
if (statusCode == 308) {
https.get("https://" + url, (response) => {
statusCode = response.statusCode;
handleRequest(statusCode);
}).on('error', () => {
// The HTTPS page wasn't found
handleRequest(statusCode);
});
} else {
handleRequest(statusCode);
}
handleRequest(statusCode);
}).on('error', () => {
// Invalid Application Name
handleRequest(404);
// This could mean the HTTPS site is not available so we check for HTTP
http.get("http://" + url, (response) => {
var statusCode = response.statusCode;
handleRequest(statusCode);
}).on('error', () => {
// Invalid Application Name
handleRequest(404);
});
});
} catch {
// An error was encountered for some unknown reason
Expand Down

1 comment on commit 80fca42

@vercel
Copy link

@vercel vercel bot commented on 80fca42 Jun 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.