geowarin/boot-react

Full Node/React UI Server + Spring Boot REST API

andersonkyle opened this issue · 3 comments

I'm curious if you've thought of going one step further and making the frontend app a standalone Node/React/Express application that taps a Spring Boot REST API for data whilst sharing the same authentication mechanism (session, jwt, oauth2, etc.)?

I've seen nearly all of the React + Spring Boot examples floating around the web and they all end up getting bundled into the Spring Boot JAR at the end. This project has the nicest separation I've seen no doubt, but was looking for a fully separate UI and API services.

Hi @kanderson450.

It IS a good idea to serve your react application with any http server (apache, nginx) or even a CDN.
A node server has the big advantage of allowing you to do server side rendering.

If you decide to go down that path, you could even remove the gradle part of the frontend and go full npm.

Please note that you will have to deal with CORS.
Your options are:

  • dealing with it on the spring server with a whitelist approach
  • Running both services behind a proxy (nginx is a good bet)

So separating both application essentially creates another class of problem and makes the application more complex to deploy.
I really wanted to be able to run the application with a single command.
It is easier to run, easier to deploy in a cloud environment.

Depending on your application needs for scaling, it might not be the best approach but it is the simplest.

Agreed. Thanks for sharing your thoughts.