Skip to content
Advertisement

React Router does not recognize direct address line changing in laravel

I use React Router and Laravel. When I navigate throught Link elements all OK, but when I change browser address line to manually show another component Laravel shows it defalt 404 page.

This is default web.php content, in welcome.blade.php I inlcude js/app.js file:

JavaScript

This is my App.js content:

JavaScript

app.js:

JavaScript

So, how to force React Router react on direct browser address line change?

Advertisement

Answer

as your working with SPA so you need to configure your web.php like this

JavaScript

then react router will catch all routes

and here api and storage routes is exclude from catch so you can use storage files and api to make call api

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement