How do I make the endpoints of an API, made with Spring Boot, visible only to the application pages?

Asked

Viewed 171 times

-1

I have an application where the back-end was done in Java with Spring Boot, and the front was done in Angular. I deploy the Angular project built into the folder src/main/Resources/Static.

In the current situation the api endpoints, consumed by the front, can also be accessed by typing their path in the browser.

Ex.: The page localhost:8080/Index.html consumes the endpoint localhost:8080/api/example to show your content.

What should I do for that route localhost:8080/api/example be accessible only for localhost:8080/Index.html?

1 answer

1


Add the dependency of the spring security module and implement the abstract class Websecurityconfigureradapter, you can in the method define the access restrictions to each path of your application, you may eventually add a JWT filter and then to access the resources you will need your front application to pass a token to each request to access the response Research articles about the module I mentioned and about its integration with the concept of JWT, probably fits your scenario

Browser other questions tagged

You are not signed in. Login or sign up in order to post.