Sign in

On the browserrouter of react-router4?

Alvant edited in Sat, 30 Jul 2022

I use the create react app scaffold to create a project. I see the document that browserrouter uses the H5 history API localhost:8080/test Refresh under this URL and 404 will be returned, because a request will be made to this address.

The question is, why can't I refresh 404 locally under this URL? In theory, it should be 404

After I upload it to GitHub pages by using yarn buld package, I download it in localhost : eight thousand and eighty / Test will refresh 404, why? Create - react - Does the app deal with local users?

1 Replies
commented on Sat, 30 Jul 2022

The reason why 404 is not available locally is that webpack dev server is configured with historyapi fallback. But after you go online, the server, or if you send it to GitHub pages, won't use webpack dev server. Webpack dev server is only useful for development. It can start local services and improve efficiency.

Configuration of webpack dev server

lock This question has been locked and the reply function has been disabled.