How to run WeInRe with cross domain restriction on web

Problem

I am trying to run WeInRe, installed on my mac as a nodejs module. But, the client does not load the javascript, because nodejs server runs on port 8080, and my site runs on 80.

Any help on how can I resolve this issue?

Thanks, pd

Problem courtesy of: pd1980

Solution

Found it! The solution is to run the NodeJS server alongside Apache on the same port.

http://arguments.callee.info/2010/04/20/running-apache-and-node-js-together/

Here is the final solution to run apache website on port 80, node js service on port 8080 and use .htaccess RewriteRule from above blog post, modified to run WeInRe module through nodejs.

In the DocumentRoot of the apache website, add the following:

Options +FollowSymLinks -MultiViews

<IfModule mod_rewrite.c>

RewriteEngine on

# Include the WeInRe javascript in the client like this:
# <script src="http://your.domain.com/node/target/target-script-min.js#xyz"></script>
# Access the WeInRe console like this:
# http://your.domain.com/node/client#xyz
RewriteRule ^node/(.*) http://your.domain.com:8080/$1 [P]

# Redirect for all the calls WeInRe makes from the client
RewriteRule ^ws/(.*) http://your.domain.com:8080/ws/$1 [P]

This will route all the WeInRe calls to the port 8080 at the server, but will not affect the client, and so no cross-domain errors.

Solution courtesy of: pd1980

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.