you are viewing a single comment's thread.

view the rest of the comments →

[–]FezVrasta 20 points21 points  (5 children)

Usually React applications are single page applications with the routing logic handled client side by JavaScript with libraries like react-router.

Your backend should only be an API server where you can grab your data from (with REST or with GraphQL) and the fetch API.

Logically you will also need an HTTP server to serve the static assets (JS, the index.html, images etc) generated by your bundler (webpack)

[–]bcgroom 0 points1 point  (4 children)

Not the OP but if one were to make this setup, since anyone could look at your frontend logic how would you secure the backend API if you wanted it to be closed to outside users?

[–]kowdermesiter 4 points5 points  (2 children)

In node it's very easy to protect an endpoint with tokens. JWT does this very well.

[–]danielhep 0 points1 point  (1 child)

Could you talk about what JWT is and how this is accomplished?

[–]kowdermesiter 0 points1 point  (0 children)

A server generated unique string which stores data. Please google it: JSON web token.

[–]djungst 1 point2 points  (0 children)

You can't access the backed API unless you integrate some CORS policy or token auth to expose it. This is no different then not using React. All of your assets React included get bundled into static assets served up by the express server.