1

I use webpack (1.12.2), react (0.14.2), react-router (1.0.0-rc4) and history (1.13.0) libraries.

When I build project with webpack, in google chrome console I get error:

Uncaught SecurityError: Failed to execute 'replaceState' on 'History': A history state object with URL 'file:///Users/and/devel/Wond/index.html' cannot be created in a document with origin 'null'.

In createBrowserHistory.js line 41.

In my source code (index.jsx) I use createBrowserHistory:

var createBrowserHistory = require('history/lib/createBrowserHistory');
let history = createBrowserHistory();

ReactDOM.render(<Router routes={routes} history={history} />, document.getElementById('content'));
Matt
  • 8,195
  • 31
  • 115
  • 225
  • 1
    https://stackoverflow.com/questions/32398578/history-replacestate-no-longer-working-in-chrome-for-local-file – Andreas Nov 04 '15 at 13:08
  • Then I get error: `Warning: Location "/Users/and/devel/Wond_dist/index.html" did not match any routes` – Matt Nov 08 '15 at 11:03

2 Answers2

5

Your document has the origin 'null' because you are loading it from a file scheme URI.

Install a web server and load your HTML document from there.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

To elaborate off of Quentin's answer. You can run it on a web server using:

npx http-server Wond_dist

Where Wond_dist is the public or distribution folder.

You can read more about http-server here: https://github.com/http-party/http-server

There are also many more web servers you can run it on in this post: Using Node.js as a simple web server

Ian
  • 1,746
  • 1
  • 15
  • 28