Plugin for ExpressionEngine that sets Cross-origin resource sharing (CORS) headers
PHP
Latest commit e9dc35b Dec 22, 2016 @derekjones derekjones initial commit
Permalink
Failed to load latest commit information.
cross_origin_headers initial commit Dec 22, 2016
.editorconfig initial commit Dec 22, 2016
.gitignore initial commit Dec 22, 2016
.travis.yml initial commit Dec 22, 2016
README.md initial commit Dec 22, 2016
composer.json initial commit Dec 22, 2016
composer.lock initial commit Dec 22, 2016

README.md

Cross-Origin Headers

Adds an Access-Control-Allow-Origin header to any request made to a template that includes this tag.

Requirements

  • ExpressionEngine 3

Installation

  1. Download the latest release.
  2. Copy the cross_origin_headers folder to your system/user/addons folder (you can ignore the rest of this repository's files).
  3. In your ExpressionEngine control panel, visit the Add-On Manager and click Install next to "Cross-Origin Headers".

Usage

{exp:cross_origin_headers}

Example Usage

The Cross-Origin Headers plugin is a single tag that you can put anywhere in your template. It might be best to put it near the top, or at least in your template comments so it's clear to anyone reading your template for the first time what's going on.

{exp:cross_origin_headers}

Parameters

domain= (default: *)

A specific domain to allow cross-origin access. The default * will allow the request to come from any source, essentially making this a public resource.

{exp:cross_origin_headers domain='http://example.com'}

Due to a practical restriction in implementation of the Access-Control-Allow-Origin standard, you can only specify a single origin. Therefore this plugin works when you want a fully public resource, or restricted to a single origin. If you need endpoints to be available from multiple domains, but not be public, then you will need to handle that in your server configuration. See the article Cross-Origin Resource Sharing for potential options.

Note: You must specify the protocol (http://, https://) with the domain, as each are treated as separate origins.

Change Log

1.0.0

  • Initial release. Boom!

Additional Files

You may be wondering what the rest of the files in this package are for. They are solely for development, so if you are forking the GitHub repo, they can be helpful. If you are just using the add-on in your ExpressionEngine installation, you can ignore all of these files.

  • .editorconfig: EditorConfig helps developers maintain consistent coding styles across files and text editors.
  • .gitignore: .gitignore lets you specify files in your working environment that you do not want under source control.
  • .travis.yml: A Travis CI configuration file for continuous integration (automated testing, releases, etc.).
  • .composer.json: A Composer project setup file that manages development dependencies.
  • .composer.lock: A list of dependency versions that Composer has locked to this project.

License

Copyright (C) 2016 EllisLab, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL ELLISLAB, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of EllisLab, Inc. shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from EllisLab, Inc.