rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

CORS OPTIONS Access-Control-Allow-Methods issues #183

Closed balutbomber closed 5 years ago

balutbomber commented 5 years ago

Checklist

My Environment

Software Version
Operating System Mac
Jets 1.6.8
Ruby 2.5.3

Expected Behaviour

OPTIONS resources returns Access-Control-Allow-Methods with all supported HTTP Methods for the path.

Current Behavior

When deploying an API Gateway fronted lambda function ALL options resources are configured to return Access-Control-Allow-Methods = 'OPTIONS,GET' even on paths that support other methods.

Step-by-step reproduction instructions

You can do a simple bootstrap of a jets app with the example /posts and then do OPTIONS requests on /posts and /posts/{id}

Code Sample

jets new demo
cd demo
jets generate scaffold Post title:string
vim .env.development # edit with local db settings
jets db:create db:migrate
jets server

curl -i -X OPTIONS http://localhost:8888/posts | grep Access-Control-Allow-Methods
curl -i -X OPTIONS http://localhost:8888/posts/12345 | grep Access-Control-Allow-Methods

UPDATE: I just realized my example above only suggests local server....if you do the commands below you will get the same results.

jets deploy
curl -i -X OPTIONS http://#{deployed_url}/posts | grep Access-Control-Allow-Methods
curl -i -X OPTIONS http://#{deployed_url}/posts/12345 | grep Access-Control-Allow-Methods
tongueroo commented 5 years ago

Released in v1.6.9