I am quite new in Spring Cloud Feign and trying to send HTTP header which is required by service provider. Here is the code snippet
@FeignClient(name = "authentication", url = "http://localhost:3000/api")
public interface AuthenticationService {
@PostMapping(value = "/login")
JsonNode login(@RequestHeader("Origin") String origin, @RequestBody LoginParams parameters);
}
When I try to send Origin
header then server does not receive this header. But other headers like referer
or x-access-token
are received at server successfully.
I have also tried using RequestInterceptor
and was not successful to send Origin
as header.
@Component
public class HeaderInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate requestTemplate) {
requestTemplate.removeHeader("origin");
requestTemplate.header("origin", "http://amjad.localhost:3000/");
}
}
Any hint or help would be much appreciated.
cheers!
question from:
https://stackoverflow.com/questions/65890036/how-to-send-origin-header-in-feign-client 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…