Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access any of my routes when deployed to heroku...working fine on localhost #61

Open
pardeepgoyal07 opened this issue Jun 4, 2020 · 1 comment

Comments

@pardeepgoyal07
Copy link

here is my code for index.js :-
const express = require('express')
require('./db/mongoose')
const userRouter = require('../src/routers/userRouter')
const taskRouter = require('../src/routers/taskRouter')
const app = express()
const port = process.env.PORT
// app.use((req,res,next)=>
// {
// res.status(503).send('App under maintainance')
// })
app.use(express.json())
app.use(userRouter)
app.use(taskRouter)
app.listen(port,()=>{
console.log('Server is up and running on port ',port)
})

For userRouter :-
const express = require('express')
const User = require('../models/user-model')
const router = new express.Router()
const { deletemsg } = require('../../email/deletemsg')
const {welcomeEmail} = require('../../email/account')
const sharp = require('sharp')
const auth = require('../middleware/auth')
const multer = require('multer')
router.post('/users',async (req,res)=>{
const user = new User(req.body)
try{
await user.save()
welcomeEmail(user.email,user.name)
const token = await user.generatejwt()
res.status(201).send({user,token})
}catch(e){
res.status(404).send()
}
})
router.post('/users/login',async (req,res)=>
{
const user = await User.findbyCredentials(req.body.email,req.body.password)
const token = await user.generatejwt()
if(!user)
{
return res.status(400).send('Unable to login')
}
res.status(200).send({user,token})
})

@irhamputra
Copy link

have you looked into Heroku Logs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants