@CrossOrigin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Spring REST Concepts")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Internal=
=Internal=


* [[Spring_Security_Concepts#CORS_Support|Spring Security Concepts]]
* [[Spring_REST_Concepts#Annotations|Spring REST Concepts]]
* [[Spring_REST_Concepts#Annotations|Spring REST Concepts]]
* [[Cross-Origin_Resource_Sharing#CORS_Support_in_Spring|CORS]]
=Overview=
The application can be configured to generate the [[Cross-Origin_Resource_Sharing#Access-Control-Allow-Origin|Access-Control-Allow-Origin]] [[Cross-Origin_Resource_Sharing#CORS_Support_in_Spring|CORS]] header by configuring the REST controller with @CrossOrigin. @CrossOrigin adds header that configure the browser to consume (or not) the API.
=Example=
<syntaxhighlight lang='java'>
@RestController
@RequestMapping(path="/inhabitants", produces = "application/json")
@CrossOrigin(origins="*")
public class InhabitantsController {
  ...
}
</syntaxhighlight>

Latest revision as of 23:49, 29 March 2019

Internal

Overview

The application can be configured to generate the Access-Control-Allow-Origin CORS header by configuring the REST controller with @CrossOrigin. @CrossOrigin adds header that configure the browser to consume (or not) the API.

Example

@RestController
@RequestMapping(path="/inhabitants", produces = "application/json")
@CrossOrigin(origins="*")
public class InhabitantsController {
  ...
}