skip to Main Content

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


  1. If redirecting outside react app, why don’t you use window.location.href? Try it out.

    Login or Signup to reply.
  2. 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:

    --
      -- frontend
      -- symfony
    

    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:

    "scripts": {
    ...
      "build": "npm run build && cp build/index.html ../symfony/templates/index/index.html.twig && cp -R build/static/ && cp -R build/static/* ../symfony/public/static/",
    },
    "homepage": "/static/",
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search