How can I enable cors on openshift?

What approaches are recommended for cross-domain ajax?

  • I'm working on a project that will have a REST API with cross-domain access required and cross-browser support. Multiple websites will access this common API. We cannot use a server-side proxy on these websites We need to do more than just GET data (need POST, PUT, and DELETE) We'd like to support the largest set of browsers possible We need to support some older browsers, but we haven't determined exactly where to draw the line. Any recommendations on where to draw this line would help. It seems like requiring IE8 or greater would simply things, but what if we also want IE7 support? We'd like to use CORS when possible, but fall back to other methods for older browsers. Are there tools, frameworks, or plugins to help accomplish this? Is this doable without using iFrames? I'm looking into the following, but it seems like many of these solutions may be outdated. Are there more modern solutions that still fall back for older browsers? easyXDM to enable cross-window/iframe communication, with the iframe accessing the API host postMessage for cross-window/iframe communication JSONP, but this means that POST information must be URL encoded, requiring our API to support more than just pure REST CORS is definitely the way to go, but would cut out a large set of users. Looks like it is only possible in newer IE browsers via XDomainRequest. Any other techniques? Has anyone created a JS library to do this with fallback support?

  • Answer:

    If you own the server that will be receiving the cross-domain XHR (AJAX request), you can allow it by using the Access-Control-Allow-Origin header. Let's say your app is written in PHP, and you want anybody to make an AJAX request against your app. Simply: header("Access-Control-Allow-Origin: *"); And that will allow all domains to make an XHR request. See here for more info: https://developer.mozilla.org/en/http_access_control

Burak Kanber at Quora Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.