The CORS extension

Cross-Origin Resource Sharing

This extension is used to allow other servers to serve pages requesting data on that one using XmlHttpRequest. It adds headers to the server response and handle preflight OPTIONS requests to indicate if some client side code has the right to access resources.

See the CORS specifications for more informations.

To use that extension, load OCamlfind package ocsigenserver.ext.cors, either from your Dune file (if you are using static linking), or from the configuration file:

<extension findlib-package="ocsigenserver.ext.cors"/>

This page describes the configuration file options. If you are building a statically linked executable without configuration file, use the corresponding functions from module Cors.

config

The extension is activated by the <cors/> tag.

The extension must be used after the extension serving the content (like eliom or staticmod) since it adds headers to already answered requests.

The attributes of the cors tag are:

Note that the extension should be used with accesscontrol to limit the application having access to the resources. This is done by checking the "origin" header.

Examples