We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have written this simple proxy/static web server that first checks to see if a local copy exist, if not then it proxy to an application server.
It is a simple GET request with no query strings.
Here is the guts of the code:
server.createServer((req: Request, res: any) => { let fileName = isFileLocal(req.url); if (fileName) { fs.readFile(fileName, "binary", function (err: string, file: any) { if (err) { res.writeHead(500, { "Content-Type": "text/plain" }); res.write(err + "\n"); res.end(); return; } else { res.writeHead(200, { "Cache-Control": "no-cache, no-store, must-revalidate" }); res.write(file, "binary"); res.end(); } }); } else { console.log("Proxying Request: %s", hostname + req.url); console.log(req.headers) proxy.web(req, res, { target: hostname + req.url }); // res.writeHead(200, { 'Content-Type': 'text/plain' }); // res.write('Request successfully proxies!' + '\n' + JSON.stringify(req.headers)); // res.end(); } }).listen(port);
Suggestions on what I am doing wrong?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have written this simple proxy/static web server that first checks to see if a local copy exist, if not then it proxy to an application server.
It is a simple GET request with no query strings.
Here is the guts of the code:
Suggestions on what I am doing wrong?
The text was updated successfully, but these errors were encountered: