spring-cloud / spring-cloud-openfeign

Support for using OpenFeign in Spring Cloud apps
Apache License 2.0
1.22k stars 786 forks source link

How Feign Client to request https instead of HTTP? #684

Closed Rutik333 closed 2 years ago

Rutik333 commented 2 years ago

My service is configured to https , registered on Eureka server. when I use @FeignClient(value = "my-service-name") it is always request serves over http how to change it to Https

Sample output : [POST] to [http://consumer-service/oty/consumer/tracesByApis] ----Actual [POST] to [https://consumer-service/oty/consumer/tracesByApis] ------Expectation

Rutik333 commented 2 years ago

If I use @FeignClient(name = "my-service-name" , url = "https://localhost:5012") then I get https but I don't want this hardcoded url can you please help me to solve this issue

OlgaMaciaszek commented 2 years ago

Hello @Rutik333, if you wish to usehttps scheme for load-balanced calls, you need to make sure that the instances returned for the serviceId the client communicates with will have https scheme or be marked as secure. If any of these is true, https scheme will be set for the URI generated by SC OpenFeign. Here's the code that resolves it.