I have the folder structure like this :
- Client // it holds react app
- Node_modules
- App.js // it is where server code is.
- Package.json
- Package-lock.json
I need to deploy it to heroku. Inside one of the file of react app. I have : It is the only file communicating with backend.
axios.post('http://localhost:5000/api/form' , data)
.then(()=>{
console.log('message sent')
}).catch(err=>{
console.log('failed');
})
Now in app.js ( backend file ) , i had :
const express = require('express') ;
const bodyParser = require('body-parser');
const nodemailer = require('nodemailer') ;
const cors = require('cors');
const port = process.env.PORT || 5000 ;
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended : false}));
app.post('/api/form' , (req , res)=>{
//something
})
app.listen(port , ()=>{
//something
})
So, what are the things i should change or add to deploy it in heroku.