I'm trying to establish a private channel using Pusher on a local node.js server. For some reason, I can't get my auth endpoint to play nice and I keep getting a 404 error.
At first I thought it was an issue with how I was defining my endpoint in relation to the location of the local server, but I don't think that's problem. More likely, my noobiness with server-client-api communication means I'm missing some big piece.
I've looked through the authentication docs on pusher and literally every SO thread I could find, but to no avail.
I've got node installed and the server running, and pusher recognizes that a connection is made, I'm just failing at the authentication.
Any help at all would be mightily appreciated.
Here's the client-side JS that is called when a button is clicked over at index.html:
In client.js:
function startGame(){
var nameinput = prompt("Give your game a name","My Game");
if (nameinput !== null) {
var initialsinput = prompt("What are your initials?", "MG");
if (initialsinput !== null) {
var pusher = new Pusher(key);
Pusher.channel_auth_endpoint = 'http://localhost:8080/pusher/auth.js';
var channel = pusher.subscribe("private-"+gamename);
joined = 'client-opponent_joined'+gamename;
channel.bind('client-opponent_joined'+gamename, function(data) {
OnLikeDonkeyKong(data.nameinput,data.initialsinput);
});
}
else {alert("I need your initials.");}
}
else {alert ("I need a game name.");}
}
Then, over in /pusher/auth.js:
var express = require( 'express' );
var Pusher = require( 'pusher' );
var app = express( express.logger() );
app.use( express.bodyParser() );
var pusher = new Pusher( { appId: 'xxx', key: 'xxx', secret: 'xxx' } );
app.post( '/pusher/auth.js', function( req, res ) {
var socketId = req.body.socket_id;
var channel = req.body.channel_name;
var auth = pusher.authenticate( socketId, channel );
res.send( auth );
} );
var port = process.env.PORT || 8080;
app.listen( port );
Finally, here's the error I'm getting:
POST http://localhost:8080/pusher/auth.js 404 (Not Found)