Enable Preview for Hosted Mode (#844)

This commit is contained in:
Steve Faulkner
2021-05-27 22:13:18 -05:00
committed by GitHub
parent 481ff9e7fe
commit 5417e1e120
5 changed files with 23 additions and 4 deletions

View File

@@ -62,6 +62,17 @@ app.get("/pull/:pr(\\d+)", (req, res) => {
})
.catch(() => res.sendStatus(500));
});
app.get("/", (req, res) => {
fetch("https://api.github.com/repos/Azure/cosmos-explorer/branches/master")
.then((response) => response.json())
.then(({ commit: { sha } }) => {
const explorer = new URL(
"https://cosmos-explorer-preview.azurewebsites.net/commit/" + sha + "/hostedExplorer.html"
);
return res.redirect(explorer.href);
})
.catch(() => res.sendStatus(500));
});
app.listen(port, () => {
console.log(`Example app listening on port: ${port}`);