My app is built with react and Symfony 4.
I use Symfony 4 for all the backend as well as all the public parts of the site for SEO purposes (blog/landing page/legals and so on).
Now I would like to redirect my user from my react app to my webapp (after he/she logs out).
For example, I would like my-app.com/logout
to be on a Symfony webpage and NOT on my react app. So from my-app.com/dashboard
, if I click logout (or landing page or blog) I go to my-app.com/logout
(or landingpage or blog).
How would I do that? A friend told me I should create a sub domaine. Is there any other way?
Thanks a lot.
2
Answers
If redirecting outside react app, why don’t you use
window.location.href
? Try it out.I would let Symfony handle all the routing.
We have a similar setup, React App and Symfony Backend and our git repository has the following structure:
where frontend contains all the React stuff.
We only deploy the symfony part to our Webserver (via Jenkins) and during the build the index.html and assets are copied to the symfony folder. So our package.json looks something like this:
So for /dashboard or /index or just / -> serve your react stuff and for the additional pages/routes like /logout or /blog create seperate routes, controllers and templates.