简体   繁体   中英

Redux - How to deploy Express Server to Heroku

I have created an app for login and log out users. Im using express and Redux

I have 2 folders, one for the client and another for the server side. It works on localhost, but now i want to make it online using heroku. I know how to deploy simple app´s in Heroku, but not apps whit server, im not understanding the logic. I have created a database using mongolab, but thats it, i dont know what to do more.

Please Help.

This is my index.js on my server.

const express = require('express');
const http = require('http');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const app = express();
const router = require('./router');
const mongoose = require('mongoose');
const cors = require('cors');

// DB Setup
//mongoose.connect('mongodb://localhost:hugo/hugo');
mongoose.connect('mongodb://*****:********@ds143608.mlab.com:43608/portfolio');

// App Setup
app.use(morgan('combined'));
app.use(cors());
app.use(bodyParser.json({type: '*/*'}));
router(app);

// Server Setup

const port = process.env.PORT || 3090;
const server = http.createServer(app);
server.listen(port);
console.log('Server Listening On:', port);

The best solution would be to combine the client and server into ONE app and deploy that to Heroku:

https://daveceddia.com/create-react-app-express-backend/

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