How to create a proxy server of my own in JAVA to solve CORS issue?

2.1k views Asked by At

i really need to create my own proxy service in java to handle CORS issue for any server/service. I was using cors-anywhere node js based service to solve my issue.

https://github.com/Rob--W/cors-anywhere

But , now i need to make this service in java. The idea is that my team members will ping this service and provide their server url as a parameter and i need to act as a middleman to fetch the response and reroute it to my teammates along with the 'no-access-allow-origin' response header.

1

There are 1 answers

2
Optional On

Yes, just have a jersey service or servlet in java running, pass the "URL" you want to call, and all the parameters, body etc to this servlet.

Then you can use HTTPClient ot java.net API to make HTTP call to the URL passed with all the details/credentials etc and then you return the response of server writing it to your servlet response or jersey entity.