K
K
Konstantin Artyushkevich2018-06-17 09:58:35
Java
Konstantin Artyushkevich, 2018-06-17 09:58:35

Spring boot restful backend interaction with frontend?

Hello. I am writing a SPA application. I ran into a problem with the interaction between a backend written in Java using Spring Boot 2 and a frontend using vue.js. The essence of the question: how to properly organize access to the site? As far as I understand there are 2 ways:

  1. Spring is running on a remote server. The resource folder contains index.html, scripts, and other static content. For any non-API request, Spring returns index.html.
  2. Frontend is running on a separate server through a node.js environment. All requests to the site go there, and vue.js sends requests to the api to another remote server to Spring.

I tried to implement option 1, but I ran into a lot of problems, because Spring MVC is primarily MVC, not REST. Therefore, you have to be smart about all sorts of workarounds so that all requests are redirected to index.html, somehow process resources separately, and even Spring Security creates smut with its access to resources. In short, I spent a lot of time, but did not quite manage to implement it.
Therefore, now I want to try option 2, but here you already need to configure CORS, and it will probably be more expensive to launch it .. But maybe I'm wrong.
Actually the question is: how is it customary to do it now, and maybe there are some other options that are actively used now?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-06-17
@sergey-gornostaev

Spring MVC is primarily MVC, not REST

You are comparing soft to warm. REST is a request/response format convention and MVC is an application architecture. Moreover, RESTful services are just very well implemented within the framework of MVC.
Create questions with specific problems and they will help you solve them.
If you study it, on the contrary, it begins to help.
This is some strange option with an additional point of failure and complication of maintenance.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question