The problem is probably that Laravel doesn't know about the route, and therefore returns a 404. You could fix that by adding a wildcard route, that always returns the same blade view (as the index). The React router will probably pick up on the route, and show the correct content.
Laravel Mix solution to historyApiFallback
I am creating a Laravel + React combo in the same source code, meaning my react front end is in the Laravel folder. Laravel has the job for authentication, authorization and API while the React will only be responsible for the /dashboard.
I bought a theme in ThemeForest to integrate React and everything, loaded the files as resolved in laravel-mix and finally got the theme running.
One major blockage I have is when the browser is manually refreshed, it'll fall back to the 404 route on Laravel instead of loading react routes again. My research suggested I would turn on historyApiFallback and include it in my webpack config so I did.
mix.webpackConfig({
devServer: {
contentBase: [path.resolve('./resources/assets/js/src')],
historyApiFallback: true,
},
modules: [
path.resolve('./resources/assets/js/src'),
path.resolve('./node_modules')
]
}
});
Yes, even though I overrode the config with historyApiFallback: true,, still don't work.
Please or to participate in this conversation.