javascript - Express and node.js run from a folder; all links point to url root -


i have installed node inside folder , forwarding through apache. doing because have several virtualhosts run through apache, , not want take time set through node. apache , node.js on same server

however, trying create chat engine. try include js files, search http://example.org/myscript.js instead of http://example.org/chat/myscript.js

i got around using

<base href="/chat/"> 

however, trying integrate socket.io. included socket.io https://cdn.socket.io/socket.io-1.3.5.js because not locally serverd /socket.io/socket.io.js located.

now socket.io trying connect http://example.org/socket.io dierectory not exist. if anything, proper path should http://example.org/chat/socket.io

i have been looking on internet solution. there must fundamental or obvious how nodejs/express operates missing. million!

server.js - file start node.

var express = require('express'); var path = require('path'); var app = express(); var http = require('http').createserver(app); var io = require('socket.io').listen(http, { log: true, resource:'/socket.io/'});  app.use('/socket.io', express.static(path.join(__dirname,'/node_modules/socket.io/lib/'))); app.use('/bootstrap', express.static(path.join(__dirname,'/node_modules/bootstrap/dist/'))); app.use('/', express.static(__dirname));   var server = app.listen(8000);  io.sockets.on('connection', function(socket) {   console.log('a user connected!'); }) 


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -