git hub app:
const App = () => {
return (
<Router>
<div className="App">
<Header/>
<Route path = '/path' component = { PathPage }/>
<Route path = '/' component = { HomePage }/>
<Footer/>
</div>
</Router>
);
}
package.json
{
"name": "name",
"version": "0.1.0",
"private": true,
"dependencies": {
"@glidejs/glide": "^3.4.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"node-sass": "^4.13.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"gh-pages": "^2.2.0"
},
"homepage": "https://username.github.io/appname"
}
menifest.json
{
"short_name": "name",
"name": "name",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
}
heroku app:
const App = () => {
return (
<Router>
<div className="App">
<Header/>
<Switch>
<Route path = '/path/:username' component = { PathPage }/>
<Route path = '/' component = { HomePage }/>
</Switch>
</div>
</Router>
);
frontend package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"homepage": "https://appname.herokuapp.com",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"express-generator": "^4.16.1",
"highcharts": "^8.0.4",
"highcharts-react-official": "^3.0.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
manifest.json
{
"short_name": "name",
"name": "name",
"start_url": ".",
}
backend server.js
if (process.env.NODE_ENV === 'production') {
app.use(express.static(path.join(__dirname, 'frontend/build')));
}
if (process.env.NODE_ENV !== 'production') {
const corsOptions = {
origin: 'http://localhost:3000',
credentials: true
};
app.use(cors(corsOptions));
}
any suggestions ?
EDIT:
NOW WHEN I ADDED
app.get('*', (req, res) => {
res.sendfile(path.resolve(__dirname, 'frontend/build/index.html'));
});
TO THE BACK END, THE WEBSITE IGNORES ALL BACKEND API REQUESTS