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

160
Visualizações
Is it possible to render a html file that doesn't belong to the react project while proxying servers request on development mode?

I am working on a react project, but my boss wants me to add a third-party index.html file to the project. The idea is to create a button that redirects to this other page. I created an endpoint in the server

app.get('/openscad', function(req, res) {
  res.sendfile(path.join(__dirname, '/openscad/index.html'));
});

to return the index.html file everytime /openscad is requested. I started the server and react (on development)

npm start
node server.js

and I proxy requests from localhost:3000 to the server (localhost:5000). When I get request /openscad directly to localhost:5000 it renders my html, but when I request it to localhost:3000 it won't render. I just get a http status 200 OK, but no html is returned.

This is my react index file

import React, { Component } from "react";
import ReactDOM from 'react-dom';
import Viewer from './viewer';
import Login from './login';
import {
  BrowserRouter as Router,
  Switch,
  Route
} from "react-router-dom";
import HomePage from "./homePage";
import ProfilePage from "./profilePage";

class App extends Component {

  render() {
    return (
      <Router>
        <Switch>
          <Route path="/viewer">
            <Viewer />
          </Route>
          <Route path="/access">
            <Login />
          </Route>
          <Route path="/profile">
            <ProfilePage />
          </Route>
          <Route path="/home">
            <HomePage />
          </Route>
        </Switch>
      </ Router>    
    )
  }
}

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

I want it to render in development so I don't have to build my project every time I want to test this new feature. Is it possible do render my index.html when requesting it localhost:3000?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As far as I know create react app server just returns index.html for every request which isn't a static file. Try to place your third party html inside /public and then redirect to the full path (/public/other.html).

If that doesn't work, you'll have to either proxy or maybe eject in order to change the configs.

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