简体   繁体   中英

how can i solve a 503 error cannot get in heroku?

I dont know what is happening first i have tried used Vercel, and in dev mode it works perfectly but when i deployed it it doesnt work, next i have tried deployed in heroku and it throws the same error, i have comment the cors thinking that it is the problem but it doesnt work too.

index.js:

const express = require('express')
const bodyParser = require('body-parser')
const jwt = require('jsonwebtoken')
const cors = require('cors')
const session = require('express-session')
const { config } = require('./config')
const Mongo = require('./Lib/Mongo')
const ProductsRoutes = require('./Routes/api/ProductsRoutes')
const CotizacionesRoutes = require('./Routes/api/CotizacionesRoutes')
const CategoriasRoutes = require('./Routes/api/CategoriasRoutes')
const passport = require("passport");
const users = require("./routes/api/UsersRoutes");

const app = express();
/* Database */
Mongo(app)
/* ------------------ Confiurations ------------------ */
// ----- cors - develop -
// app.use(cors());

/* ------------------- Middlewares ------------------ */
bodyParser.urlencoded({
    extended: false
})

app.use(session({
    resave: false,
    saveUninitialized: false,
    secret: "keyboard cat"
}))
app.use(bodyParser.json());

// Passport middleware
app.use(passport.initialize());
// Passport config
require("./config/passport")(passport);
// Routes
app.use("/api/users", users);

app.use('/api/productos', ProductsRoutes);
app.use('/api/cotizacion', CotizacionesRoutes);
app.use('/api/categorias', CategoriasRoutes);

app.listen(config.port)

在此处输入图片说明

这不是服务器中的错误,而是文件夹结构上的错误,必须在名为 app 的文件夹中包含 api 并在其中包含路由、控制器、模型等......它对我有用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM