# Cross-origin resource sharing (CORS)

How do I configure my application for CORS?

The best solution is to use Sanic Extensions. However, if you would like to build your own version, you could use this limited example.

    $ curl localhost:9999/ -i
    HTTP/1.1 200 OK
    Access-Control-Allow-Methods: OPTIONS,POST,GET
    Access-Control-Allow-Origin: mydomain.com
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Headers: origin, content-type, accept, authorization, x-xsrf-token, x-request-id
    content-length: 3
    connection: keep-alive
    content-type: text/plain; charset=utf-8
    ...
    $ curl localhost:9999/ -i -X OPTIONS     
    HTTP/1.1 204 No Content
    Access-Control-Allow-Methods: GET,POST,OPTIONS
    Access-Control-Allow-Origin: mydomain.com
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Headers: origin, content-type, accept, authorization, x-xsrf-token, x-request-id
    connection: keep-alive
    

    Also, checkout some resources from the community:

    MIT Licensed
    Copyright © 2018-present Sanic Community Organization

    ~ Made with ❤️ and ☕️ ~