- 
                Notifications
    
You must be signed in to change notification settings  - Fork 594
 
feat: CORS-support #4343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: CORS-support #4343
Conversation
        
          
                akka-http/src/main/scala/akka/http/scaladsl/server/directives/CorsDirectives.scala
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | with WebSocketDirectives | ||
| with FramedEntityStreamingDirectives | ||
| with AttributeDirectives | ||
| with CorsDirectives | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can cause problems for users having the original cors directive imported and also using Directives to import all built in, because method names will collide.
Maybe that is fine though and the recommendation is to move over to the built in cors support?
91eb5b9    to
    64b1f3f      
    Compare
  
    | 
           The overhead for regular CORS requests is a bit more expensive than I would have hoped, up to 10%, but couldn't find a way to optimise it further (it needs to copy/filter headers).  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be better just benching the directive/route rather than an end to end server test over TCP, but might be good enough for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, maybe we should start a migration-guide page informing about this addition and how to migrate?
| 
               | 
          ||
| # Configuration for the cors directive, does not apply unless the directive is used | ||
| #cors | ||
| cors { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both package names and config are different from akka-http-cors, so there shouldn't be any problems for users that still have akka-http-cors in classpath, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is what I mentioned in #4343 (comment)
We have an import-all directives-object/baseclass, now including cors(), if the original library is also in scope that will clash and not compile, not entirely sure what happens for the scenario of bumping without recompiling (but the original library does not support newer Akka versions so maybe that is a non issue?)
| 
           I agree, a migration page of some sort would be good to add. Will do.  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Based on https://github.com/lomigmegard/akka-http-cors but simplified here and there with less API surface, also a few optimisations.