Skip to content

Commit

Permalink
Redirect landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Dec 30, 2024
1 parent db5289a commit f3ab9f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ app.use(function(req, res, next){
});

// check if package/universe exists and handle caching values
app.use('/:package', function(req, res, next){
app.use('/{:package}', function(req, res, next){
if(!production){
res.set('Cache-Control', 'no-cache');
return next();
}
const universe = res.locals.universe;
const pkg = req.params.package;
const reserved = ["api","apis","articles","badges","bin","builds","citation","contributors","datasets","docs",
const pkg = req.params.package || "";
const reserved = ["", "api","apis","articles","badges","bin","builds","citation","contributors","datasets","docs",
"favicon.ico","feed.xml","index.xml","manual","packages","readme","robots.txt","sitemap_index.xml",
"sitemap.xml","src","stats"] ;
"sitemap.xml","src","stats", ""] ;
const metapage = reserved.includes(pkg);
if(pkg == '_global'){
var query = {};
Expand Down
9 changes: 8 additions & 1 deletion routes/universe.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ function retry_url(x){

/* Langing page (TODO) */
router.get('/', function(req, res, next) {
res.render('index');
//res.render('index');
res.set('Cache-control', 'private'); // Vary does not work in cloudflare currently
const accept = req.headers['accept'];
if(accept && accept.includes('html')){
res.redirect(`/builds`);
} else {
res.send(`Welcome to the ${res.locals.universe} universe!`);
}
});

router.get('/builds', function(req, res, next) {
Expand Down

0 comments on commit f3ab9f2

Please sign in to comment.