rubyonjets / jets

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

Specifying the authorizer in the routes.rb with CORS enabled breaks jets. #473

Closed iqre8 closed 1 year ago

iqre8 commented 4 years ago

Specifying the authorizer in the routes.rb with CORS enabled breaks jets.

Checklist

My Environment

Software Version
Operating System OSX 10.13.6
Jets 2.3.16
Ruby ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin17]

Expected Behaviour

jets deploy should work. CORS should be enabled.

Current Behavior

When enabling CORS or when specifying the authorizer in routes.rb causes a deployment failure. When trying to manually enable CORS in AWS you see "Invalid Response status code Specified"

Step-by-step reproduction instructions

Enable CORS Specify the authorizer in the routes.rb Perform a jets deploy

03:40:19PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack api-dev User Initiated
03:40:23PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiGateway 
03:40:23PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPreheatJob 
03:40:23PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiGateway 
03:40:25PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack ApiResources1 
03:40:26PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack MainAuthorizer 
03:40:26PM UPDATE_COMPLETE AWS::CloudFormation::Stack ApiResources1 
03:40:28PM UPDATE_IN_PROGRESS AWS::CloudFormation::Stack JetsPublicController 
03:40:37PM UPDATE_FAILED AWS::CloudFormation::Stack MainAuthorizer Embedded stack arn:aws:cloudformation:eu-west-1:123456789024:stack/api-dev-MainAuthorizer-ABCDEFGHIJKL/e4aa2950-87ec-11ea-9236-01234567890a was not successfully updated. Currently in UPDATE_ROLLBACK_IN_PROGRESS with reason: The following resource(s) failed to update: [MyCognitoAuthorizer]. 
03:40:37PM UPDATE_FAILED AWS::CloudFormation::Stack JetsPreheatJob Resource update cancelled
03:40:48PM UPDATE_FAILED AWS::CloudFormation::Stack JetsPublicController Resource update cancelled
03:40:48PM UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack api-dev The following resource(s) failed to update: [JetsPublicController, MainAuthorizer, JetsPreheatJob]. 

Code Sample

https://github.com/iqre8/jets-example-api/commit/cc051aa427caee891930888febdf38f8d6dbd83a

Solution Suggestion

For now I just enable CORS, and specify the authorizer in the controller.

tongueroo commented 1 year ago

Dug into this. Tried to reproduce and wasn't able to. Guessing that some point between 2.3.16 and the current version it was fixed. Thanks for the report.