Hi Campers,
I face a problem with Heroku. I set database and deploy my nodes app ( URL Shortener Microservice ) then the site didn’t redirect to the site, Although it redirect to the specific URL from database on my localhost
It looks like you’re asking for the wrong property.
When you create the short link, it makes two properties, orginal_url (original is spelled funny there ) and url. But in the route above, you’re looking for link.
Try changing the route to:
app.get('/:id', ( req, res, next ) => {
URL.findOne({ _id: req.params.id }).then( url => {
if( url ) res.redirect( url.orginal_url )
else res.send({ error: "This url is not on the database." })
})
})