Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
How to connect Frontend ReactJs Project Folder with NodeJs Backend?

I Have a React web app that has crypto portfolio, Now I want to connect it with Backend server.js. The deployed web app should set start from Node Server. I am fairly new with NodeJS but Ive tried solutions like cors and all.

I am Fairely New to node can anyone please help me to connect my React folder to backend node folder. I'll be very grateful.

In react I've made Production Build also but it didn't worked.

Here's Server.js Code:

const express = require('express');
const cors = require('cors');
const path = require('path');

app.use(express.json({ extended: false }));

app.use((req, res, next) => {
  res.header('Access-Control-Allow-Origin', '*');
  res.header(
    'Access-Control-Allow-Headers',
    'Origin, X-Requested-With, Content-Type, Accept'
  );
  next();
});
if (process.env.NODE_ENV === 'production') {
  //static folder
  app.use(express.static('client/build'));
  app.get('/', (req, res) => {
    res.sendFile(path.resolve(__dirname, 'client', 'build', 'index.html'));
  });
}

Now I am Getting the error in server

connot GET /

Github Project Link of frontend: https://github.com/Twelve03/crypto-portfolio

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you are starting the server using the code app.listen(3000); And it's still not working, then you might have to set the environment variable NODE_ENV=production you can do it like this NODE_ENV=production node server.js

Better practice will be to keep all you environment variables inside a .env file and then use the dotenv package to read the environment variables from the .env file

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!