SEARCH BY

All

  • All
  • Java8
  • Spring

Enabling Cross Origin Request for REST endpoints

Post a Comment
In this article we are going to learn how to allow to access REST endpoints by different domain origins.

For example our REST endpoint is http://localhost:8082/studentData

if we want to access the above REST endpoint in http://localhost:9090 then we need to enable cross origin for the above end point.

There are two ways to enable cross origin to access REST endpoints
1) is by using @CrossOrigin annotation

2) by using CorsRegistry


CORS -- Cross Origin Resource Sharing

we can use @CrossOrigin at method level and class level

if we use at class level then all the endpoints created in the RestController will be enabled for the corssorigin

@CrossOrigin(origins="domain name or url her")




jaya
I love software designing, coding, writing and teaching...

Share this article

Related Posts

Post a Comment

Place your code in <em> </em> tags to send in comments | Do not add hyper links in commnet

Close

Subscribe our newsletter for the latest articles directly into your email inbox