forked from WINOFFRG/widevine-license-proxy-server-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (36 loc) · 1.04 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const express = require('express');
const cors = require('cors');
const axios = require('axios');
const bodyParser = require('body-parser');
const app = express();
const port = 5000;
const BASE_URL = '/api';
app.use(bodyParser.raw({type: "application/octet-stream"}));
app.use(cors());
app.post(`${BASE_URL}/license`, async (req, res) => {
getLicense(req,res);
});
async function getLicense(req, res) {
let licenseUrl = 'https://cwip-shaka-proxy.appspot.com/no_auth';
let rurl = `${licenseUrl}`;
let config = {
method: 'POST',
url: rurl,
headers: {
"content-type" : "application/octet-stream"
},
data : new Int8Array((req.body)),
responseType: 'arraybuffer',
};
axios(config)
.then(function (response) {
// console.log("Served Request");
res.status(response.status).send(response.data);
})
.catch(function (error) {
return res.status(400).send(error);
});
}
app.listen(port, () => {
console.log(`Listening on port ${port}`)
});