Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable CORS in Sails.js on OpenShift

I'm trying to enable CORS in SailsJS v0.9.15... It doesn't help if i set "allRoutes: true" in cors.js, i'm still getting CORS related errors. Why is this not working? According to this, it should be enough... https://github.com/balderdashy/sails-docs/blob/master/todo/config.cors.md

Error in Firefox: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at www.domain.com. This can be fixed by moving the resource to the same domain or enabling CORS."

Error in Chrome: "The 'Access-Control-Allow-Origin' header contains the invalid value 'null'. Origin 'www.domain.com' is therefore not allowed access."

Is this a bug?

Sails.js (REST api) is hosted on Openshift, could that be a problem?

Thanks for help...

like image 216
cartoonle Avatar asked Nov 11 '22 06:11

cartoonle


1 Answers

Just to make this official, there is an open issue about CORS headers being filtered out by OpenShift. CORS should work fine in Sails for deployments that don't block those headers. Documentation for CORS in Sails is here and here.

like image 197
sgress454 Avatar answered Nov 14 '22 21:11

sgress454