A
A
adizh2021-06-30 16:12:54
AJAX
adizh, 2021-06-30 16:12:54

Server not working after deploying react app?

The application is running locally, getting data from the server and rendering on the client, but after deploying to heroku, the server data is not shown to the
server:

const express = require('express');
/* const bodyParser = require('body-parser'); */
const server = express();
const port =  8090;
const cors = require('cors');
server.use(cors());
/* server.use(bodyParser.json()); */

 server.get('/api/v1/startup', (req, res) => {
    res.send(
       JSON.stringify(
        [{"startup_id":1,"startup_name":"Mangoswap",
}]
server.listen(port);

package.json
"scripts": {
    "start": "react-scripts start",
    "server": "nodemon server/server.js",
    "dev": "concurrently \"yarn run start\" \"yarn run server\"",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

Apps on heroku only work fine when I log in and run scripts locally. And how can I make it so that the data from the server is rendered without my intervention through localhost?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question