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")
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")
Post a Comment
Post a Comment