• 1000 Я бы использовал
app.set('view engine', 'ejs');
, но я использую реакцию - MERN.
Nodejs:
const express = require('express');
const logger = require('morgan');
const passport = require('./passport/');
const PORT = process.env.PORT || 8080;
const app = express();
const mongoose = require('mongoose');
mongoose.connect('mongodb', {useNewUrlParser: true})
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
app.use(passport.initialize());
app.use(passport.session());
app.use(session({
resave: false,
saveUninitialized: false,
secret: 'secret here',
store: new MongoStore({ mongooseConnection: mongoose.connection })
}))
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use('/', indexRouter);
app.use('/authentication', usersRouter);
if (process.env.NODE_ENV === 'production') {
app.use(express.static('client/build'))
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "../client", "build", "index.html"))
})
}
app.listen(PORT);
module.exports = app
package. json:
{
"name": "name",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon app.js",
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
}
}
}
Кто-нибудь знаете, как это исправить?
-Спасибо тонну