title: Play Framework 2.3 - CORS Headers
body: <p><strong>UPDATE</strong> the new Play 2.5 offers a new <a href="https://www.playframework.com/documentation/2.5.x/CorsFilter" rel="nofollow noreferrer">CORS Filter</a> </p>
  
  <p>As the new 2.3 Java version finished the migration of the Response class to Promise class the following code no longer works.</p>
  
  <pre><code>public class CorsAction extends Action.Simple {
  
   public Result call(Context context) throws Throwable{ 
   Response response = context.response(); 
   response.setHeader("Access-Control-Allow-Origin", "*"); 
   //Handle preflight requests 
   if(context.request().method().equals("OPTIONS")) { 
     response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE"); 
     response.setHeader("Access-Control-Max-Age", "3600"); 
     response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-    Type, Accept, Authorization, X-Auth-Token"); 
     response.setHeader("Access-Control-Allow-Credentials", "true"); 
     response.setHeader("Access-Control-Allow-Origin", "*"); 
   return ok() 
  
   } 
  
   response.setHeader("Access-Control-Allow-Headers","X-Requested-With, Content-Type, X-    Auth-Token"); 
   return delegate.call(context); 
   } 
  }
  </code></pre>
  
  <p>I am developing an application in Play (Java) 2.3 and I have looked and tried different methods to enable CORS -including adding /OPTIONS methods to the routes file- without success.</p>
  
  <p>I would much appreciate some light on how the new Response implementation would handle this type of interception, because it seems not to have any effects in the headers when implemented in the new Promise class.</p>
  
  <p>Thanks in advance for all the help!!</p>