2

I'm using the node-phantom npm module, and whenever I do a super simple test like

phantom=require('node-phantom');
var phantom=require('node-phantom');
phantom.create(function(err,ph) {
    console.log("testing");
    ph.exit();
});

It prints the following error: phantom stdout: console msg:XMLHttpRequest cannot load http://127.0.0.1/socket.io/?EIO=3&transport=polling&t=1439501157936-0. Origin http://127.0.0.1:60689 is not allowed by Access-Control-Allow-Origin.

Anyone know what the cause of this could be?

package.json:

{
  "name": "test",
  "version": "0.0.1",
  "devDependencies": {
    "grunt": "^0.4.5",
    "grunt-contrib-clean": "^0.6.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-exec": "^0.4.6",
    "mocha": "^2.2.5",
    "node-phantom": "^0.2.5",
    "phantom": "^0.7.2",
    "phantomjs": "^1.9.18",
  }
}

(there are multiple versions of phantom because I've been trying some out)

3
  • Show us the package.json and the command you execute npm test? Commented Aug 13, 2015 at 21:30
  • Try phantom instead of node-phantom. It has basically the same API, but a different communication setup. Are you on windows by the way? Commented Aug 13, 2015 at 21:32
  • @EmilioPlatzer I'm running the script directly with node test.js (my file is called test.js). Not trying to tie in with a test suite right now, literally just trying to get my environment set up and nothing is working. Commented Aug 13, 2015 at 21:40

1 Answer 1

4

Changed window.location.hostname to window.location.host in node-phantom.js file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, yeah I found this too. This technically works, but I wish there's a better way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.