Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
609 views
in Technique[技术] by (71.8m points)

How to send 'Origin' header in Feign Client

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...