GeneralistDev / SSD2-Backend

SSD2 Project backend play framework
Apache License 2.0
0 stars 0 forks source link

Major Feature: CORS (Cross Origin Resource Sharing) Support #7

Closed GeneralistDev closed 10 years ago

GeneralistDev commented 10 years ago

This feature though small is a major one that allows angularJS to actually make requests to the Play Framework without getting failed requests due to CORS not being supported. To support CORS this feature provides a single route that captures all OPTIONS requests and sends them to the checkPreFlight() method in the controller. That method will set all the required headers and respond with 200 OK.

Please review that it works with the AngularJS http requests and that code looks ok.

Commits: d163c4f DOC-NEW: Comments in routes and Application.java to describe the CORS support methods 25ce8d3 ADDED: Support for CORS by adding a preflight method that accepts all OPTIONS http requests and sets headers so that cross origin requests can be performed

grim-fendango commented 10 years ago

It works with the angular front end. All good.

Note that invalid requests i.e., putting when the model doesn't exist yet gives the same error as before (when there was no rout for preflight checking, as seen below). "XMLHttpRequest cannot load http://localhost:9000/vismodel/10. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:9001' is therefore not allowed access."

Daniel create a pull request and assign to Huan.

GeneralistDev commented 10 years ago

Closing this as it has been pulled to master. There was still a small error which has been moved to issue #11