I'm building a nodejs server and I need to access more services using ajax from another domain, so how can I break the cross-domain restriction in nodejs code?
Note: Frameworks like ExpressJS is not an acceptable solution
I'm building a nodejs server and I need to access more services using ajax from another domain, so how can I break the cross-domain restriction in nodejs code?
Note: Frameworks like ExpressJS is not an acceptable solution
Generally speaking, when there is a cross domain restriction in effect you have two possible options to take.
Determine if the remote party you're trying to talk to supports CORS. Have them allow your domain on their end in the HTTP headers. Sometimes this is not possible.
Setup a reverse HTTP proxy that allows you to communicate to the remote party but goes through your web server first so you bypass the cross domain origin security issue. Node-http-proxy is a possible solution if you're already using Node.js
CORS is generally only supported in more recent browsers, so if you have a requirement to support old stuff that might not be suitable.
Note in jQuery from linked resource.
$.support.cors
boolean will be set to true if the browser supports CORS