Whenever I use browserHistory on local i have no issues, but when i test it before I ship it i get a blank page with the error. So when i replace browserHistory with hashHistory everything works fine, but i lose the pretty url.
Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/somefile/work/someproject/index.html' cannot be created in a document with origin 'null' and URL.
const Routes = (
<Router history={browserHistory}>
<Route path="/" component={Login} />
<Route path="/content" component={App} >
<Route path="/component1" component={component1} />
<Route path="/component2" component={component2} />
<Route path="/component3" component={component3} />
</Route>
</Router>
);
in my index.js
const createStoreWithMiddleware = applyMiddleware(ReduxPromise)(createStore);
const store = createStoreWithMiddleware(reducers);
ReactDOM.render(
<Provider store={store}>
{Routes}
</Provider>,
document.querySelector('.react-internal')
)
in my app.js
export default class App extends Component {
render() {
return (
<div>
<Header />
<div className="container-fluid">
{this.props.children}
</div>
</div>
);
}
}
and my webpack file
var webpack = require('webpack');
module.exports = {
devtool:'source-map',
entry: [
'./src/index.js',
],
output: {
path: __dirname,
publicPath: '/',
filename: 'bundle.js'
},
module: {
loaders: [
{
exclude: /node_modules/,
loaders: ['react-hot','babel']
},
{ test: /\.css$/, loader: "style!css" },
{
test: /\.(jpe?g|png|gif|svg)$/i,
loaders: [
'file?hash=sha512&digest=hex&name=[hash].[ext]',
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
devServer: {
port:8080,
historyApiFallback: true,
contentBase: './'
}
};