I've got a simple RepositoryRestResource based off of the guides on spring.io
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long>{
List<Person> findByLastName(@Param("name") String lastName);
}
This does indeed work, as my REST client returns
{
"_links" : {
"people" : {
"href" : "http://127.0.0.1:8080/people{?page,size,sort}",
"templated" : true
},
"profile" : {
"href" : "http://127.0.0.1:8080/profile"
}
}
}
But my question is, where does the http://127.0.0.1:8080 part of the _links come from and how can I change it? When my application goes to production (or any of my environments, like local or dev), I'd rather be able to see something like http://api.mydomain.com.
If it matters, I'm compiling my program with mvn package and running it as a standalone jar on the server.
The host and port of your URL are figured out by using HttpServletRequest#getRequestURL (or getRequestURI). So it will always reflect the host and port used by the client when performing the request.
Once you deploy that as api.yourdomain.com, this is what you'll get in the link URLs.