trailsjs / sails-swagger

Swagger integration for sails.js
107 stars 47 forks source link

Request/Response not served from SailJS because of CORS issue #40

Open swaroopjayanthi9 opened 7 years ago

swaroopjayanthi9 commented 7 years ago

I am running Web REST API on Swagger, Sail JS, when I am trying to access through Angular UI,. I have set the required headers in the UI and as well as enabled in sailjs > config/cors.js file with below values.

allRoutes: true, origin: '*', credentials: true,

From the UI application, I am setting below headers before sending any request. this.headers = new Headers({ 'Content-Type': 'application/json', 'Accept': 'q=0.8;application/json;q=0.9' }); this.headers.set('Access-Control-Allow-Origin' , '*'); this.headers.set('Access-Control-Allow-Methods', 'GET,POST,PUT,HEAD,DELETE,OPTIONS'); this.headers.set('Access-Control-Allow-Headers', 'origin, content-type, accept'); this.headers.append('Access-Control-Allow-Credentials', 'true'); this.headers.append('Access-Control-Max-Age' , '86400');

But I am not able to get the response from Sail JS, can you please let me know if I am missing anything or do I need enable any other settings on the SailJS config.

Please do the needful to resolve this issue.