forked from mschae/cors_plug
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Schaefermeyer
committed
Jan 22, 2016
1 parent
34cd34e
commit 23b783f
Showing
4 changed files
with
266 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="generator" content="ExDoc v0.11.3"> | ||
<title>Changelog – cors_plug v1.0.0</title> | ||
<link rel="stylesheet" href="dist/app-ddd9717ad9.css" /> | ||
<script src="dist/sidebar_items.js"></script> | ||
</head> | ||
<body data-type="extras"> | ||
|
||
<div class="main"> | ||
<button class="sidebar-toggle"> | ||
<i class="icon-menu"></i> | ||
</button> | ||
<section class="sidebar"> | ||
<button class="sidebar-toggle"> | ||
<i class="icon-menu"></i> | ||
</button> | ||
|
||
|
||
<a href="api-reference.html" class="sidebar-projectLink"> | ||
<div class="sidebar-projectDetails"> | ||
<h1 class="sidebar-projectName"> | ||
cors_plug | ||
</h1> | ||
<h2 class="sidebar-projectVersion"> | ||
v1.0.0 | ||
</h2> | ||
</div> | ||
|
||
</a> | ||
|
||
<div class="sidebar-search"> | ||
<i class="icon-search"></i> | ||
<input type="text" class="sidebar-searchInput" placeholder="search" autocomplete="off" /> | ||
</div> | ||
|
||
<ul class="sidebar-listNav"> | ||
<li><a id="extras-list" href="#full-list">Pages</a></li> | ||
|
||
|
||
<li><a id="modules-list" href="#full-list">Modules</a></li> | ||
|
||
|
||
|
||
|
||
|
||
</ul> | ||
|
||
<ul id="full-list" class="sidebar-fullList"></ul> | ||
<div class="sidebar-noResults"></div> | ||
</section> | ||
|
||
<section class="content"> | ||
<div id="content" class="content-inner"> | ||
|
||
|
||
<h1>Changelog</h1> | ||
<h2 id="v1-0-0"> v1.0.0</h2><ul> | ||
<li>Fixes | ||
</li> | ||
<li>Don’t override headers. Earlier headers would’ve been overriden by the | ||
CORS Plug. Amazing that this hasn’t popped up before… | ||
</li> | ||
</ul> | ||
<p>As this makes a backward-incompatible change (no longer overriding headers | ||
this is a new major).</p> | ||
<h2 id="v0-1-4"> v0.1.4</h2><ul> | ||
<li>Enhancements | ||
</li> | ||
<li>Add <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Expose-Headers"><code class="inline">Access-Control-Expose-Headers</code></a> (thanks @jaketrent) | ||
</li> | ||
</ul> | ||
<h2 id="v0-1-3"> v0.1.3</h2><ul> | ||
<li>Enhancements | ||
</li> | ||
<li>Add license | ||
</li> | ||
<li>Improve readme (thanks @leighhalliday, @patricksrobertson) | ||
</li> | ||
<li>Simplify travis.yml (thanks @lowks) | ||
</li> | ||
</ul> | ||
<h2 id="v-0-1-2"> v.0.1.2</h2><ul> | ||
<li>Release plug dependency | ||
</li> | ||
</ul> | ||
|
||
<footer class="footer"> | ||
<p> | ||
<span class="line"> | ||
Built using | ||
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.11.3), | ||
</span> | ||
<span class="line"> | ||
designed by | ||
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>. | ||
</span> | ||
</p> | ||
<button class="night-mode-toggle" /> | ||
</footer> | ||
</div> | ||
</section> | ||
</div> | ||
<script src="dist/app-6d2e071366.js"></script> | ||
</body> | ||
</html> | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta name="generator" content="ExDoc v0.11.3"> | ||
<title>README – cors_plug v1.0.0</title> | ||
<link rel="stylesheet" href="dist/app-ddd9717ad9.css" /> | ||
<script src="dist/sidebar_items.js"></script> | ||
</head> | ||
<body data-type="extras"> | ||
|
||
<div class="main"> | ||
<button class="sidebar-toggle"> | ||
<i class="icon-menu"></i> | ||
</button> | ||
<section class="sidebar"> | ||
<button class="sidebar-toggle"> | ||
<i class="icon-menu"></i> | ||
</button> | ||
|
||
|
||
<a href="api-reference.html" class="sidebar-projectLink"> | ||
<div class="sidebar-projectDetails"> | ||
<h1 class="sidebar-projectName"> | ||
cors_plug | ||
</h1> | ||
<h2 class="sidebar-projectVersion"> | ||
v1.0.0 | ||
</h2> | ||
</div> | ||
|
||
</a> | ||
|
||
<div class="sidebar-search"> | ||
<i class="icon-search"></i> | ||
<input type="text" class="sidebar-searchInput" placeholder="search" autocomplete="off" /> | ||
</div> | ||
|
||
<ul class="sidebar-listNav"> | ||
<li><a id="extras-list" href="#full-list">Pages</a></li> | ||
|
||
|
||
<li><a id="modules-list" href="#full-list">Modules</a></li> | ||
|
||
|
||
|
||
|
||
|
||
</ul> | ||
|
||
<ul id="full-list" class="sidebar-fullList"></ul> | ||
<div class="sidebar-noResults"></div> | ||
</section> | ||
|
||
<section class="content"> | ||
<div id="content" class="content-inner"> | ||
|
||
|
||
<h1>CorsPlug</h1> | ||
<p><a href="https://travis-ci.org/mschae/cors_plug"><img src="https://travis-ci.org/mschae/cors_plug.svg" alt="Build Status"/></a></p> | ||
<p>An <a href="http://github.com/elixir-lang/plug">Elixir Plug</a> to add <a href="http://www.w3.org/TR/cors/">CORS</a>.</p> | ||
<h2 id="Usage"> Usage</h2><ol> | ||
<li>Add this plug to your <code class="inline">mix.exs</code> dependencies: | ||
</li> | ||
</ol> | ||
<pre><code class="elixir">def deps do | ||
# ... | ||
{:cors_plug, "~> 0.1.4"}, | ||
#... | ||
end</code></pre> | ||
<p>When used together with the awesomeness that’s the <a href="http://www.phoenixframework.org/">Phoenix Framework</a> | ||
please note that putting the CORSPlug in a pipeline won’t work as they are only invoked for | ||
matched routes.</p> | ||
<p>I therefore recommend to put it in <code class="inline">lib/your_app/endpoint.ex</code>:</p> | ||
<pre><code class="elixir">defmodule YourApp.Endpoint do | ||
use Phoenix.Enpoint, otp_app: :your_app | ||
|
||
# ... | ||
plug CORSPlug | ||
|
||
plug YourApp.Router | ||
end</code></pre> | ||
<p>Alternatively you can add options routes, as suggested by @leighhalliday</p> | ||
<pre><code class="elixir">scope "/api", PhoenixApp do | ||
pipe_through :api | ||
|
||
resources "/articles", ArticleController | ||
options "/articles", ArticleController, :options | ||
options "/articles/:id", ArticleController, :options | ||
end</code></pre> | ||
<h2 id="Configuration"> Configuration</h2><p>This plug will return the following headers:</p> | ||
<p>On preflight (<code class="inline">OPTIONS</code>) requests:</p> | ||
<ul> | ||
<li>Access-Control-Allow-Origin | ||
</li> | ||
<li>Access-Control-Allow-Credentials | ||
</li> | ||
<li>Access-Control-Max-Age | ||
</li> | ||
<li>Access-Control-Allow-Headers | ||
</li> | ||
<li>Access-Control-Allow-Methods | ||
</li> | ||
</ul> | ||
<p>On <code class="inline">GET</code>, <code class="inline">POST</code>, … requests:</p> | ||
<ul> | ||
<li>Access-Control-Allow-Origin | ||
</li> | ||
<li>Access-Control-Expose-Headers | ||
</li> | ||
<li>Access-Control-Allow-Credentials | ||
</li> | ||
</ul> | ||
<p>You can configure the value of these headers as follows:</p> | ||
<pre><code class="elixir">plug CORSPlug, [origin: "example.com"]</code></pre> | ||
<p>Please find the list of current defaults in <a href="lib/cors_plug.ex#L5:L13">cors_plug.ex</a>.</p> | ||
<h2 id="License"> License</h2><p>Copyright 2014 Michael Schaefermeyer</p> | ||
<p>Licensed under the Apache License, Version 2.0 (the “License”); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at</p> | ||
<pre><code class="elixir">http://www.apache.org/licenses/LICENSE-2.0</code></pre> | ||
<p>Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an “AS IS” BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License.</p> | ||
|
||
<footer class="footer"> | ||
<p> | ||
<span class="line"> | ||
Built using | ||
<a href="https://github.com/elixir-lang/ex_doc" title="ExDoc" rel="help" target="_blank">ExDoc</a> (v0.11.3), | ||
</span> | ||
<span class="line"> | ||
designed by | ||
<a href="https://twitter.com/dignifiedquire" target="_blank" title="@dignifiedquire">Friedel Ziegelmayer</a>. | ||
</span> | ||
</p> | ||
<button class="night-mode-toggle" /> | ||
</footer> | ||
</div> | ||
</section> | ||
</div> | ||
<script src="dist/app-6d2e071366.js"></script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters