Skip to content

Commit

Permalink
Updates to note common issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyu authored Dec 19, 2020
1 parent 43a1882 commit 47af8a8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Read more about it here in the [Rails Guides](https://guides.rubyonrails.org/con

### Rack Configuration

NOTE: If you're running Rails, updating in `config/application.rb` should be enough. There is no need to update `config.ru` as well.
NOTE: If you're running Rails, adding `config/initializers/cors.rb` should be enough. There is no need to update `config.ru` as well.

In `config.ru`, configure `Rack::Cors` by passing a block to the `use` command:

Expand Down Expand Up @@ -109,6 +109,15 @@ A Resource path can be specified as exact string match (`/path/to/file.txt`) or

## Common Gotchas

### Origin Matching

When specifying an origin, make sure that it does not have a trailing slash.

### Testing Postman and/or CURL

* Make sure you're passing in an `Origin:` header. That header is required to trigger a CORS response.
* Make sure your origin does not have a trailing slash.

### Positioning in the Middleware Stack

Positioning of `Rack::Cors` in the middleware stack is very important. In the Rails example above we put it above all other middleware which, in our experience, provides the most consistent results.
Expand Down

0 comments on commit 47af8a8

Please sign in to comment.