Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

258
Views
How do I change the server name in the links in a Spring RepositoryRestResource?

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.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!