cors.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * Cross-Origin Resource Sharing (CORS) Settings
  3. * (sails.config.cors)
  4. *
  5. * CORS is like a more modern version of JSONP-- it allows your server/API
  6. * to successfully respond to requests from client-side JavaScript code
  7. * running on some other domain (e.g. google.com)
  8. * Unlike JSONP, it works with POST, PUT, and DELETE requests
  9. *
  10. * For more information on CORS, check out:
  11. * http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
  12. *
  13. * Note that any of these settings (besides 'allRoutes') can be changed on a per-route basis
  14. * by adding a "cors" object to the route configuration:
  15. *
  16. * '/get foo': {
  17. * controller: 'foo',
  18. * action: 'bar',
  19. * cors: {
  20. * origin: 'http://foobar.com,https://owlhoot.com'
  21. * }
  22. * }
  23. *
  24. * For more information on this configuration file, see:
  25. * http://sailsjs.org/#/documentation/reference/sails.config/sails.config.cors.html
  26. *
  27. */
  28. module.exports.cors = {
  29. /***************************************************************************
  30. * *
  31. * Allow CORS on all routes by default? If not, you must enable CORS on a *
  32. * per-route basis by either adding a "cors" configuration object to the *
  33. * route config, or setting "cors:true" in the route config to use the *
  34. * default settings below. *
  35. * *
  36. ***************************************************************************/
  37. // allRoutes: false,
  38. /***************************************************************************
  39. * *
  40. * Which domains which are allowed CORS access? This can be a *
  41. * comma-delimited list of hosts (beginning with http:// or https://) or *
  42. * "*" to allow all domains CORS access. *
  43. * *
  44. ***************************************************************************/
  45. // origin: '*',
  46. /***************************************************************************
  47. * *
  48. * Allow cookies to be shared for CORS requests? *
  49. * *
  50. ***************************************************************************/
  51. // credentials: true,
  52. /***************************************************************************
  53. * *
  54. * Which methods should be allowed for CORS requests? This is only used in *
  55. * response to preflight requests (see article linked above for more info) *
  56. * *
  57. ***************************************************************************/
  58. // methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD',
  59. /***************************************************************************
  60. * *
  61. * Which headers should be allowed for CORS requests? This is only used in *
  62. * response to preflight requests. *
  63. * *
  64. ***************************************************************************/
  65. // headers: 'content-type'
  66. };