Reputation: 209
i have a problem. i am trying to proxy pass my form submits to an endpoint that is behind a firewall. Only my Spring Application can access it.
I want to proxy pass GET and POST request
here is an example for my POST request:
<form action="/proxy/mail" method="post" encType="multipart/form-data">
<input id="file" class="file" type="file" name="file" >
<input type="text" name="firstname" value="test">
<input type="submit" value="Submit">
</form>
@RequestMapping("/proxy/**")
@ResponseBody
public String mirrorRest(@RequestBody(required=false) String body, HttpMethod method, HttpServletRequest request, HttpServletResponse response){
if(!user_is_allowed())){
return "NO!!!!"
}
//TODO: proxy request to http://my-service-behide-firewall/mail
return result
}
i tried with restTemplate.exchange but had problems with multipart/form-data
does someone know how to manage this proxy request?
Upvotes: 1
Views: 1592
Reputation: 56
refer This Link
In this article, we’ll explore the communication between a front-end application and a REST API that are deployed separately.
The goal is to work around CORS and the Same Origin Policy restriction of the browser and allow the UI to call the API even though they don’t share the same origin.
We’ll basically create two separate applications – a UI application and a simple REST API, and we’ll use the Zuul proxy in the UI application to proxy calls to the REST API.
Zuul is a JVM based router and server side load balancer by Netflix. And Spring Cloud has a nice integration with an embedded Zuul proxy – which is what we’ll use here.
Upvotes: 1