You need to explicitly allow '127.0.0.1:3000/connect' to be accessed from
'localhost:8080' by serving CORS headers in your node.js application.
See http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
On Wednesday, 17 April 2013 12:21:25 UTC+10, soewij wrote:
>
> Hello, I'm new to node.js.
> I'm running a server, listen on 127.0.0.1:3000,
>
> var express = require('express');
> var EventEmitter = require('events').EventEmitter;
> var emitter = new EventEmitter();
> var app = express.createServer();
> var fs = require('fs');
>
> var eventQueue = [];
> var queueStart = 0;
>
> app.configure(function(){
> emitter.setMaxListeners(0);
> app.use(express.logger());
> app.set('port', process.env.PORT || 3000);
> app.use(express.bodyParser());
> app.use(express.static(__dirname + '/public', { maxAge: 86400}));
> });
>
> // receives connect events
> app.post('/connect', function(req, res){
> eventQueue.push({ua: req.body.ua});
> emitter.emit("connect", req.body.ua);
> res.end();
> });
>
> app.listen(app.set('port'));
> console.log("Express server listening on port %d in %s mode",
> app.address().port, app.settings.env);
>
> (My code is adapted from a w3 demo:
> http://www.w3.org/2011/11/remote-whiteboard-demo )
>
> This server is running well, and sending responses correctly to requests
> from '127.0.0.1:3000/test.html'.
> (public/test.html)
>
> Then, I was trying to serve test.html in Apache server.
> So, the requests is sent from 'localhost:8080'.
> It uses JQuery,
>
> $.post('127.0.0.1:3000/connect', {'ua': navigator.userAgent});
>
> But it always gets "*forbidden*" responses.
>
> How to configure my node.js & express code so that it allows connection
> from the Apache server?
>
> I've tried to search for solutions in the web with no results so far.
> I would appreciate any helps and suggestions.
> Thank you very much.
>
>
>
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.