@CrossOrigin: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
Line 7: Line 7:
=Overview=
=Overview=


Adds headers that configure the browser to consume (or not) the API.
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=
=Example=

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 {
  ...
}