Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

233
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda