How to enable CORS in Sails.js on OpenShift

I am trying to enable CORS in SailsJS v0.9.15 ... This does not help if I set "allRoutes: true" in cors.js, I still get CORS errors. Why is this not working? In accordance with this, this should be enough ... https://github.com/balderdashy/sails-docs/blob/master/todo/config.cors.md

Error in Firefox: "Request for cross-request is blocked: a policy of the same origin prohibits reading a remote resource on www.domain.com. This can be eliminated by moving the resource to the same domain or allowing CORS."

Error in Chrome: "The header" Access-Control-Allow-Origin "contains an invalid value of" null ". Therefore, the site" www.domain.com "is not allowed access."

This is mistake?

Sails.js (REST api) hosted on Openshift, may be the problem?

Thanks for the help...

+4
source share
1 answer

Just to make this official, there is an open problem with CORS headers filtered by OpenShift. CORS should work fine in Sails for deployments that don't block these headers. The documentation for CORS in Sails is here and here .

+1
source

Source: https://habr.com/ru/post/1543855/


All Articles