-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
primus doesn't accept custom path with engine.io #774
Comments
I cannot reproduce the issue: const Primus = require('primus');
const http = require('http');
const fs = require('fs');
const server = http.createServer(function (req, res) {
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(__dirname + '/index.html').pipe(res);
});
const primus = new Primus(server, {
pathname: '/mycustompath/primus',
transformer: 'engine.io'
});
primus.on('connection', function (spark) {
console.log(spark.id, 'connected');
});
server.listen(3000, function () {
console.log('listening on port 3000');
}); <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="/mycustompath/primus/primus.js"></script>
<script>
(function () {
var primus = new Primus({ strategy: false });
primus.on('open', function open() {
console.log('open');
});
})();
</script>
</body>
</html> Did you rebuild the client? |
It does not matter, that is just where the const Primus = require('primus');
const http = require('http');
const fs = require('fs');
const server = http.createServer(function (req, res) {
if (req.url === '/primus-client.js') {
res.setHeader('Content-Type', 'text/javascript');
fs.createReadStream(__dirname + '/primus-client.js').pipe(res);
return;
}
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(__dirname + '/index.html').pipe(res);
});
const primus = new Primus(server, {
pathname: '/mycustompath/primus',
transformer: 'engine.io'
});
primus.save(__dirname + '/primus-client.js');
primus.on('connection', function (spark) {
console.log(spark.id, 'connected');
});
server.listen(3000, function () {
console.log('listening on port 3000');
}); <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script src="/primus-client.js"></script>
<script>
(function () {
var primus = new Primus({ strategy: false });
primus.on('open', function open() {
console.log('open');
});
})();
</script>
</body>
</html> |
It means the |
I can't debug your code, sorry. That's up to you. |
You probably just have to save the client lib under the javascript folder and get it from there. primus.save('/path/to/javascript/primus.js'); <script src="/path/to/javascript/primus.js"></script> |
That is a CORS issue because you are sending a cross origin request from https://app.autoscheduler.ai to https://api.autoscheduler.ai. See https://github.com/primus/primus#getting-started and https://github.com/socketio/engine.io#methods-1. |
Requests for primus/engine.io are not handled by express. |
No, server side. |
No, |
I'm closing this. Let me know if it should stay open. |
5.1.2
Environment:
Expected result:
"https://app.application.com/mycustompath/?_primuscb=*******************"
Actual result:
"https://app.application.com/?_primuscb=*******************"
Steps to reproduce:
`var server = http.createServer(app);
var Primus = require('primus');
const Session = require('server/session');
var primus = new Primus(server, {
transformer: 'engine.io',
pathname:"/mycustompath/primus",
compression: true,
transport: {
cookie: Session.getEngineIOCookieName()
}
});
var Connection = require('server/connection');
primus.on('connection', function (spark) {
Connection.create(spark);
});
primus.on('disconnection', function (spark) {
Connection.destroy(spark);
});
/**
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);`
The text was updated successfully, but these errors were encountered: