Search the Community
Showing results for tags 'nodejs'.
-
Hey guys, I stumbled upon your awesome piece of software about a month ago. Since then I am working my way up to a complete automated build. Right now I would like to understand how the POST request works. I am trying my hardest since two days to be able to update the whitelisted IP-Addresses using nodejs. When I copy the complete json using Postman everything works just fine. But when I try to get the json from the server and just reupload it (for testing purposes) it resets my settings on the server (success code 204). It may be a simple http error that I am unable to see. Here is my nodejs playground so far. const request = require('request'); var obj request('http://localhost:8096/emby/System/Configuration?api_key=5058514e6c2443a9b03cbcbcf308f06f', (err, res, body) => { if (err) { return console.log(err); } var inbetween = JSON.parse(body); obj = inbetween; }); JSON.stringify(obj); var options = { uri: 'http://localhost:8096/emby/System/Configuration?api_key=5058514e6c2443a9b03cbcbcf308f06f', method: 'POST', json : obj }; console.log(obj); request(options, function (error, response, body) { if (!error && response.statusCode == 204) { console.log(body.id) // Print the shortened url. } console.log(response.statusCode); // console.log(body); }); If you need some server logs just say so. Eltonmaster
-
Hi Emby Community, I'm trying to set up a reverse proxy (jada jada jada ipv6 reachable from ipv4 jada jada) and for reasons I can only do it with node.js. I took inspiration from this nginx config guide as there where no guides for node.js but I'm stuck at setting the headers correctly. First I want a working setup in pure node.js and the think about using express for compression middleware and stuff like that. const http = require('http'); const PORT = 80; const hostname = 'emby.mydomain.com'; function onRequest(req, res) { console.log('serve: ' + req.url); const options = { hostname: hostname, port: 80, path: req.url, method: req.method, headers: { ...req.headers, 'X-Real-IP': '$remote_addr', 'X-Forwarded-for': '$proxy_add_x_forwarded_for', 'Host': '$host', 'X-Forwarded-Proto': '$remote_addr', 'X-Forwarded-Protocol': '$scheme', //proxy_redirect off; // websockets //proxy_http_version 1.1; 'Upgrade': '$http_upgrade', 'Connection': "upgrade" } }; const proxy = http.request(options, function (r) { res.writeHead(r.statusCode, r.headers); r.pipe(res, { end: true }); }); req.pipe(proxy, { end: true }); } http.createServer(onRequest).listen(PORT); console.log('Listening on port '+PORT); As I am not very comfortable in nginx and honestly ony a beginner in node.js I'm missing some header information, how to set http to version 1.1 (red something that thats maybe already default?) and how to translate the proxy_redirect directive. Thank you for any responses, maybe someone with some nodejs experience can help me out here.
- 12 replies