Search code examples
node.jscorsaccess-controlcanvas-lms

CORS issue solution via proxy services or curl


I'm hitting a major road block while consuming services POST from this client who has no Access-Control-Allow-Origin at all.

I've tried following solutions or are you saying it's not possible at all?

  1. Looked into JSONP but that's limited to GET only.
  2. Created a service on my domain that can make a request to client domain. Ended up with { [Error: socket hang up] code: 'ECONNRESET' }
  3. Haven't tested, but can I've it accomplished using node-curl. https://www.npmjs.com/package/node-curl

Please advise.


Solution

  • So, why just not add this header? Just one line of code :)

    You may run your own server which will forward requests to that service (nginx can easily do that, take a peek).
    In a nutshell:
    frontend app -> your proxy with CORS headers (like nginx) -> api service