grunt-contrib-jasmine and PhantomJS security

孤街浪徒 提交于 2019-11-30 14:16:01

问题


I'm getting an error

XMLHttpRequest cannot load https://my-api.domain.com. Origin file:// is not allowed by Access-Control-Allow-Origin.

when I try to run some async unit tests that query an API through grunt-contrib-jasmine, which in turn using PhantomJS. I see that the command line version of PhantomJS does have a 'web-security' options. Can I control how grunt-contrib-jasmine uses PhantomJS to include this option and disable the cross-domain security?


回答1:


You can pass options to phantomjs similarly to how you would on the command line, e.g.

The following options may help, but more can be found at the phantomjs docs

jasmine : {
  your_task : {
    options : {
      '--web-security' : false,
      '--local-to-remote-url-access' : true,
      '--ignore-ssl-errors' : true
    }
  }
}


来源:https://stackoverflow.com/questions/16826203/grunt-contrib-jasmine-and-phantomjs-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!