Why Is My @RestController Returning HTML Instead of JSON?

Profile Picture

KingSnu

OP
@snuchi.bsky.social
3 days ago

My API is expected to return JSON, but instead I keep getting an entire HTML page.

@GetMapping("/api/user")
public UserDto getUser() {
    return new UserDto("john", 25);
}
spring-boot rest-api framework