I am fairly new to React and am trying to utilize the react router feature. I am displaying Static pages on a TV screen pointing to a certain URL.
When in my Dev environment everything is working fine. When I enter the correct path it points to the set component. When loading it onto my hosting server and testing on a Live URL pointing to the desired path results in a 404.
import React, { Component } from 'react';
import './style/App.css';
import Header from './js/components/header';
import Menu from './js/components/menu';
import MenuTwo from './js/components/menuTwo';
import { BrowserRouter as Router, Route, Switch, Link } from 'react-
router-dom';
class App extends Component {
render() {
return (
<Router>
<div>
<Header headerProp="maxwell's pizzeria" />
<Route path="/" exact component={Menu} />
<Route path="/menuTwo" exact component={MenuTwo} />
</div>
</Router>
)
}
}
export default App;
The webpack.config which I am also not very familiar with is as follows:
var webpack = require('webpack');
var path = require('path');
var BUILD_DIR = path.resolve(__dirname, 'public');
var APP_DIR = path.resolve(__dirname, 'src/build');
// Existing Code ....
var config = {
// Existing Code ....
module : {
loaders : [
{
test : /\.jsx?/,
include : APP_DIR,
loader : 'babel'
}
]
}
}
module.exports = config;
/itself. If you request e.g./menuTwoit will probably try to serve the page located locally on your server which is not existing. It needs to serve your app on every route, not only on/.