Skip to content

StevenJL/cors_plug

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CorsPlug

Build Status

An Elixir Plug to add CORS.

Usage

  1. Add this plug to your mix.exs dependencies:
def deps do
  # ...
  {:cors_plug, "~> 0.0.1"},
  #...
end

Use it in a phoenix pipeline (or wherever):

pipeline :api do
  plug CORSPlug
  super
end

Configuration

This plug will return the following headers:

On preflight (OPTIONS) requests:

  • Access-Control-Allow-Origin
  • Access-Control-Allow-Credentials
  • Access-Control-Max-Age
  • Access-Control-Allow-Headers
  • Access-Control-Allow-Methods

On GET, POST, ... requests:

  • Access-Control-Allow-Origin
  • Access-Control-Allow-Credentials

You can configure the value of these headers as follows:

plug CORSPlug, [origin: "example.com"]

Please find the list of current defaults in cors_plug.ex.

About

cors-plug

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%