Using node server across domains

About Forums Forum Using node server across domains

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
  • #959


    I’m running a website (a wordpress site) on a reception area screen with some buttons beneath that make things happen on the website. The website is on an external server, the buttons are connected to a local machine. I’m using breakout on the website. I’ve tried running the Breakout Server locally and it works great for a few minutes but then seems to go to sleep and stop listening for button presses until I make the breakout server the active window and then it starts working again for another few minutes.

    I thought the solution would be to use the node server instead, but I’m getting cross domain CORS errors “XMLHttpRequest cannot load http://localhost:8887/ No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘’ is therefore not allowed access.”

    I’d really appreciate any advice you have!




    Hi Emma,

    Your project sounds cool. Another person mentioned the issue of Breakout Server not working when the window loses focus. Are you running OS X 10.9?

    Regarding the CORS issue. What IP address you’re passing to the IOBoard constructor in your code?

    If you’re using the following block of code:

        var host = window.location.hostname;
        // if the file is opened locally, set the host to "localhost"
        if (window.location.protocol.indexOf("file:") === 0) {
            host = "localhost";
        var arduino = new IOBoard(host, 8887);

    you need to change host in the IOBoard constructor to either “localhost” or the specific IP address of the computer the node server is running on. Otherwise by default host points to the content server (the wordpress site).

    Let me know if that fixes the issue for you. I may also need to add a flag to the node server to disable the ability to serve pages… leaving just the websocket bridge in that case (this is what I was getting at in my tweet… not a lot of room to reply in twitter though so thanks for posting here).


    Thank you for your reply! I’ve managed to get it working by editing the io.configure method slightly, but I actually have another problem with the node server in general – even when I run as downloaded with the examples provided. I get an error with line 72 of server.js:


    TypeError: Object � has no method ‘toJSON’
    at SerialPort.<anonymous> (/Applications/Breakout 2/node_server/server.js:72:35)
    at SerialPort.EventEmitter.emit (events.js:96:17)
    at Object.module.exports.raw [as parser] (/Applications/Breakout 2/node_server/node_modules/serialport/parsers.js:8:13)
    at Object.options.dataCallback (/Applications/Breakout 2/node_server/node_modules/serialport/serialport.js:136:15)
    at SerialPort._emitData (/Applications/Breakout 2/node_server/node_modules/serialport/serialport.js:305:20)
    at afterRead (/Applications/Breakout 2/node_server/node_modules/serialport/serialport.js:283:18)
    at /Applications/Breakout 2/node_server/node_modules/serialport/serialport.js:297:9
    at Object.wrapper [as oncomplete] (fs.js:362:17)

    Have you come across this before? Many thanks for your help.



    What versions of nodeJS and node-serialport do you have installed?


    Node is v0.8.19 – I tried upgrading to the latest version but then I couldn’t get the node server to run at all.

    node-serialport is 1.3.0


    You need Node version v0.10 or higher. I’ll look into this late tonight when I get home and can actually test this. Node and node-serialport keep making non backwards compatible changes so I find that whenever I update either, stuff breaks. It’s quite frustrating.


    Thank you so much for helping with this. I tried a few different version combinations and found that node version v0.10.12 and serialport version 1.3.0 works! serialport version 1.3.1 does not.

    Many thanks,


Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘Forum’ is closed to new topics and replies.