swarr35
swarr35

Reputation: 95

Why is this route 404?

I am trying to add a new route in Express. The route is 404.

I have tried to set the route like the others but am having issues.

var repomapRouter = require('./routes/repomap');

 ...

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hbs');

...

app.use('/repomap',repomapRouter);

This is my routes/repomap.js route

var express = require('express');
var router = express.Router();

router.get('/repomap/:vendor/:product/:image', function(req, res, next) { 
 res.render('repomap', { title: 'Repo Map'});
})

module.exports = router;

User clicks this link to hit the above listed route:

<a href="/repomap/${vendor}/${product}/${image}">Artifacts</a>

I am expecting my hbs template to render. Can someone point out what I am doing wrong?

Upvotes: 0

Views: 39

Answers (1)

Quentin
Quentin

Reputation: 943571

You've mounted the router at /repomap with the use call.

/repomap + /repomap/:vendor/:product/:image is /repomap/repomap/:vendor/:product/:image

Upvotes: 1

Related Questions