Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set-cookie: MYSPECIALCOOKIE=679b6291-d1cc-47be; Path=/app; HttpOnly
- set-cookie: MYSPECIALCOOKIE=679b6291-d1cc-47be; Path=/; HttpOnly; Secure
- httpProxy = require('http-proxy');
- httpProxy.createServer(function (req, res, proxy) {
- res.oldWriteHead = res.writeHead;
- res.writeHead = function(statusCode, headers) {
- /* add logic to change headers here */
- var contentType = res.getHeader('content-type');
- res.setHeader('content-type', 'text/plain');
- // old way: might not work now
- // as headers param is not always provided
- // https://github.com/nodejitsu/node-http-proxy/pull/260/files
- // headers['foo'] = 'bar';
- res.oldWriteHead(statusCode, headers);
- }
- proxy.proxyRequest(req, res, {
- host: 'localhost',
- port: 3000
- });
- }).listen(8000);
- response.setHeader("Set-Cookie", ["type=ninja", "language=javascript"]);
- // curl -k https://localhost:8000/
- var https = require('https');
- var fs = require('fs');
- var options = {
- key: fs.readFileSync('path_to_key.pem'),
- cert: fs.readFileSync('path_to_cert.pem')
- };
- https.createServer(options, function (req, res) {
- var body = "hello"
- res.writeHead(200,{
- 'Content-Length': body.length,
- 'Content-Type': 'text/plain',
- 'set-cookie': "MYSPECIALCOOKIE=679b6291-d1cc-47be; Path=/; HttpOnly; Secure"
- });
- res.end("hello worldn");
- }).listen(8000);
- var httpProxy = require('http-proxy');
- var server = httpProxy.createServer(function (req, res, proxy) {
- var buffer = httpProxy.buffer(req);
- req.headers['x-host'] = process.env.PROXY_URI;
- proxy.proxyRequest(req, res, {
- host: '127.0.0.1',
- port: 9000,
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement