Skip to content

Commit

Permalink
revert node-http-proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
deep-gaurav committed Jul 12, 2020
1 parent 8cbb972 commit 24cfbbf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7,584 deletions.
47 changes: 21 additions & 26 deletions api/cors/[cors].js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const allowCors = fn => async (req, res) => {
function request(uri,options,res){
const https = require('https');
const url = require("url");


console.log("Request headers");
console.log(options);
Expand Down Expand Up @@ -68,26 +69,20 @@ const handler = (req, res) => {
} = req;
var uri = Buffer.from(decodeURIComponent(cors), 'base64').toString('ascii');

const httpproxy = require("http-proxy")

var proxy = httpproxy.createProxyServer({});

proxy.web(req,res,{target:uri});

// var header = {};
// var cphead = ["x-youtube-client-name","x-youtube-client-version","range"];
// for(head of cphead){
// if(req.headers[head]){
// header[head]=req.headers[head]
// }
// }
// if(header["range"]){
// if(header["range"].endsWith("-")){
// var r = header["range"];
// r = r+ (parseInt(r.split("=")[1].split("-")[0])+1000000).toString();
// header["range"]=r;
// }
// }
var header = {};
var cphead = ["x-youtube-client-name","x-youtube-client-version","range"];
for(head of cphead){
if(req.headers[head]){
header[head]=req.headers[head]
}
}
if(header["range"]){
if(header["range"].endsWith("-")){
var r = header["range"];
r = r+ (parseInt(r.split("=")[1].split("-")[0])+1000000).toString();
header["range"]=r;
}
}
// if(req.headers["x-youtube-client-name"]){
// header["x-youtube-client-name"]=req.headers["x-youtube-client-name"];
// }
Expand All @@ -98,14 +93,14 @@ const handler = (req, res) => {
// header["range"]=req.headers["range"];
// }

// const https = require('https');
// var options = {
// headers : header
// }
const https = require('https');
var options = {
headers : header
}

// console.log(options);
console.log(options);

// request(uri,options,res);
request(uri,options,res);

// https.get(uri, options, (resp) => {
// let data = '';
Expand Down
Loading

1 comment on commit 24cfbbf

@vercel
Copy link

@vercel vercel bot commented on 24cfbbf Jul 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.