Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ynoth25's avatar

Laravel Restful API & ReactJs

I'm creating SPA using Reactjs and Laravel and used laravel passport to secure my restful api 's.

The thing is whenever I reload the page it returns a 404 error.

0 likes
1 reply
trin's avatar

you need to split front and back-end. as I understand, when you go to https://example.com, laravel generate front and react router configured for use history api in browser. and when you click to https://example.com/info, your browser call to react router. but if you refresh page, request go to laravel, not react. in classic spa case, laravel monitoring only https://example.com/api/* requests, and all other "rewrite" to index (to generate react code). in best practic, you split front and back, as i say. for example, all https://example.com/* request go to the react, web server configured only for html. laravel configured only for subdomain https://api.example.com/*

Please or to participate in this conversation.