I have two seperate projects, a projectApi (spring backend) and a projectUi (angular frontent). I'm using maven-resource-plugin to combine them into one jar for production. When I start the spring server, the connection between those two modules works fine.
Now I would like to customize the backend url path, so that a request like 'http://localhost:8088/login' looks like 'http://localhost:8088 /api/v1/login'.
I was able to do so, by adding the following entry to application.properties: spring.mvc.servlet-path=/api/v1
and modifying the base url, for calls from the ui to the api.
Since that change I'm getting a whitelabel error calling the ui (localhost:8088).
After some search, I tried to implement WebMvcConfigurer
but it did not work for me. This is the reference stackoverflow link.
// Application.java
@SpringBootApplication
@EnableJpaRepositories
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
// UserRestService.java
@RestController
@RequestMapping("/user")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class UserRestService extends AbstractRestService {
...
@PostMapping("/login")
public String login(@RequestBody User user) throws CustomException {
return Response.ok(userService.loginUser(user, response));
}
}
// application.properties
server.port=8088
// without that entry the post request works fine -> localhost:8088/user/login
// adding that entry and trying to call: localhost:8088/api/v1/user/login i get whitelabel error
spring.mvc.servlet.path=/api/v1