Example of project with create-react-app react-router-dom and expressjs

0

I have a project with create-react-app where I do all project routes with react-router-dom (since the examples with react-router are no longer updated). I need to use data from a DB in MSSQL and I am using superagent to fetch the data using url type GET.

Does anyone have an example in which express can be used, next to the app with create-react-app and that is using react-router-dom?

Or is there a way to bring the data without using url as with superagent?

    
asked by Jonathan Ludeña 03.11.2017 в 22:47
source

1 answer

2

If you want to have the backend and the frontend in the same directory you should add a proxy in your package.json so that the two applications can communicate.

Here there is an example and another one of the official documentation .

Here you can also see how to configure express to let you use client side routing Configure express with CRA

Let's say if you have express running in localhost:8080 your package.json should have the property: "proxy": "http://localhost:8080/"

    
answered by 19.04.2018 в 17:02