sails-swagger
sails-swagger copied to clipboard
/swagger/doc not using global CORS settings
My current settings for CORS are:
allRoutes: true
origin: '*'
methods: 'GET, POST, PUT, DELETE, OPTIONS'
When accessing the /swagger/doc route (with the default config) I don't get my CORS headers. Just these:
Connection:keep-alive
Date:Thu, 17 Dec 2015 22:56:49 GMT
ETag:W/"f1f7-1299879629"
X-Powered-By:Sails <sailsjs.org>
But my other routes have the CORS headers:
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://someothersite.com
Access-Control-Expose-Headers:
Connection:keep-alive
Content-Length:10887
Content-Type:text/html; charset=utf-8
Date:Thu, 17 Dec 2015 22:46:49 GMT
ETag:W/"2a87-3377312003"
X-Powered-By:Sails <sailsjs.org>
This might be a bug in sails, where manually-configured routes aren't picking up on the global CORS setting. Can you try manually defining a route for the swagger doc handler in config/routes.js, set the CORS config there, and see if that works?
Also, please see: https://github.com/tjwebb/sails-swagger/issues/16
Not (fully) doing it. I tried with cors:true
and also by explicitly defining my cors settings, still my allow-origin field is empty. It almost seems like the cors config is plainly overwritten at some point.
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:
Access-Control-Expose-Headers:
I could try taking a look inside Sails to fix the issue. Will you guys still be looking at pull requests once you jump on Trails?
Found the issue in sails-swagger
Specifying a cors config for the /swagger/doc route overwrites the global config. I simply removed the cors property from the config object.
#18
Is this fixed? I'm still having this issue. Should I be using master version?
The npm version doesn't have this fix, but I can confirm its available in the latest commit. Updating the npm version would be wonderful. Thanks
@tjwebb Would you mind updating the npm package? Thank you!
I've published an updated npm package.
npm install sails-magik-swagger
Is this abandoned? I still have the same problems described here with CORS
I am facing this issue, I am setting CORS value to true in cors.js, please suggest workaround at the earliest.
The above mentioned sails-magik-swagger isnt working