2016-04-01 10 views
-3

benim app giriş yapabilirsiniz ve giriş başarılı olduğunu gösterir ERR_CONNECTION_REFUSED, ancakhttp: // localhost: Ben sayfayı yenilediğinizde 3000/API/kullanıcıların :: net

http://localhost:3000/api/users net::ERR_CONNECTION_REFUSED 

Ben bu hatayı verir Ön tarafta Angular ile Node.js kullanarak m. Ayrıca jetonlar için JWT'yi kullanıyor.

Benim arka uç app.js:

app.use(morgan('dev')); 
    app.use(bodyParser.json()); 
    app.use(bodyParser.urlencoded({ extended: true })); 
    app.use(cookieParser()); 

mongoose.connect(config.database); 

app.use(cors({origin: "http://localhost:8000",credentials: true })); 

app.use('/api/upload/single', expressJWT({secret: config.secret})); 



app.use(function (error, request, response, next) { if (error.name === 'UnauthorizedError') { 
    response.status(401).json({message: 'You need an authorization token to view this page.'}); } }); 

// MULTER var s3config = require('./config/s3'); var upload = multer({ storage: s3({ 
    dirname: s3config.dirname, 
    bucket: s3config.bucket, 
    secretAccessKey: process.env.AWS_ACCESS_SECRET, 
    accessKeyId: process.env.AWS_ACCESS_KEY, 
    region: s3config.region, 
    contentType: function(req, file, next) { 
     next(null, file.mimetype); 
    }, 
    filename: function(req, file, next) { 
     var ext = '.' + file.originalname.split('.').splice(-1)[0]; 
     var filename = uuid.v1() + ext; 
     next(null, filename); 
    } }) }); 

// UPLOAD SINGLE FILE app.post('/api/upload/single', upload.single('file'), function(req, res) { var clothing_1 = { 
    type: req.body.type, 
    image: req.file.key }; console.log(req.body); // get the user model User.findOne({ id: req.user._id }) User.findOne({ _id: req.user._id }, {}, { new: true }, function(err, user){ 
    user.clothing.push(clothing_1); 
    // save this user 
    user.save(function(err, user){ 
     if(err) return res.status(401).send({ message: 'your error:' + err }); 
     else return res.json({ user: user }) 
    }); }); 

}); // app.get('api/users', usersController.showUser); app.use('/api', routes); 

app.listen(3000); 
+1

bize giderme amacıyla sunucu tarafı kodu gönderin. Aksi halde cevap vermek imkansızdır. – user2263572

+1

ERR_CONNECTION_REFUSED hata çalışmadığından, bu yüzden muhtemelen çöktü olduğunu gösterir. Kazaya neden olan şeyin ne olduğunu görmek için hata ayıklamak için günlüğe kaydetme veya düğüm denetleyicisini kullanma – Neil

cevap

0

çıkıyor sadece benim Açısal devletler üzerinde sağ denetleyici koyarak değil meselesiydi.

İlgili konular