I'm trying to build my react app using the command 'npm run build' but when I view the index.html file (from build folder) on browser it shows only the header and footer.
Here are the codes from my App.js file:
import React from 'react';
import './App.css';
import Header from './components/Header/Header';
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom';
import Home from './components/pages/Home';
import Resume from './components/pages/Resume';
import Contact from './components/pages/Contact';
import Footer from './components/Footer/Footer';
function App() {
return (
<Router>
<section className="mainWrap">
<Header/>
<Switch>
<Route path='/' exact component={Home} />
<Route path='/Resume' exact component={Resume} />
<Route exact path="/http://bright-webs.com/portfolio.html" render={() => (window.location = "http://bright-webs.com/portfolio.html")} />
<Route path='/Contact' exact component={Contact} />
</Switch>
<Footer/>
</section>
</Router>
);
}
export default App;
I think you are trying to deploy the react build on CPanel and experiencing this issue.
In order to resolve this issue when you upload the build zip on Cpanel, after extracting the build folder copy all files which are inside the build folder and than move it inside the public_html and now you can see your project working
Also, remember to add homepage inside package.Json before running build command.