I try to connect from my htmlpage to my expressjs app over horizon.
My server is like this [https://github.com/rethinkdb/horizon/blob/next/examples/express-server/main.js]:
#!/usr/bin/env node
'use strict'
const express = require('express');
const horizon = require('@horizon/server');
const app = express();
const http_server = app.listen(8181);
const options = { auth: { token_secret: 'my_super_secret_secret' } };
const horizon_server = horizon(http_server, options);
app.use(express.static('public'));
console.log('Listening on port 8181.');
Then i followed this link: http://horizon.io/docs/getting-started/#integrating-horizon-with-an-existing-application and created the following html:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://localhost:8181/horizon/horizon.js"></script>
<script>
var horizon = Horizon({host: 'localhost:8181'});
horizon.onReady(function() {
document.querySelector('h1').innerHTML = 'App works!'
});
horizon.connect();
</script>
</head>
<body>
<marquee><h1></h1></marquee>
</body>
</html>
my package.json dependencies:
"dependencies": {
"@horizon/server": "^1.0.3",
"express": "^4.13.4",
"horizon": "^1.0.3"
}
it results in an 400 error:
polling-xhr.js:250GET http://localhost:8181/horizon/?EIO=3&transport=polling&t=LJke5oP 400 (Bad Request)
index.js:66Received an error: Error: Websocket ws://localhost:8181 experienced an error
Whats wrong, how do i get a valid connection to my express backend? I saw this page but i dont know if it is the same problem.
Update I created a repository for my question and asked the same question on the projectpage.
Info: seems to be a bug and should be fixed in the next release.