Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda