Enable Cross-Origin Resource Sharing (CORS)

    First of all, install the CORS feature into your application.

    Here is an advanced example that demonstrates most of CORS-related API functions

    • method("HTTP_METHOD") : Includes this method to the white list of Http methods to use CORS.
    • : Includes this header to the white list of headers to use CORS.
    • exposeHeader("header-name") : Exposes this header in the response.
    • exposeXHttpMethodOverride() : Exposes X-Http-Method-Override header in the response
    • : Allows only the specified host to use CORS, it can have the port number, a list of subDomains or the supported schemes.
    • allowCredentials : Includes Access-Control-Allow-Credentials header in the response
    • allowNonSimpleContentTypes: Inclues Content-Type request header to the white list for values other than .
    • : Includes Access-Control-Max-Age header in the response with the given max age