Send to proxy /api
with all params (header/cookie/post) as docs
And get
server.js
'use strict';
const fs = require('fs'),
proxy = require('http-proxy-middleware'),
browserSync = require('browser-sync').create();
function returnIndexPageFn(req, res, next) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write(fs.readFileSync('./public/app.html'));
res.end();
next();
}
browserSync.init({
port: 88,
server: {
baseDir: 'public/',
index: 'app.html',
middleware: [
{route: '/home', handle: returnIndexPageFn},
proxy(['/api', '/media'], {
target: 'https://security-site.com',
logLevel: 'debug',
changeOrigin: true,
headers: {
Referer: 'https://security-site.com',
},
})
]
}
});
I try another with angular 5, but have the same result(((
proxy.conf.json
{
"/api": {
"target": "https://security-site.com/",
"secure": false,
"changeOrigin": true,
"logLevel": "info"
}
}
How to solve this problem?
I find solution:
Need change header Referal
to https protocol
For browser-sync
server.js
...
proxy(['/api', '/media'], {
target: 'https://security-site.com',
logLevel: 'debug',
changeOrigin: true,
headers: {
Referer: 'https://security-site.com',
},
})
...
For angular 5 (angular cli): proxy.conf.json
{
"/api": {
"target": "https://security-site.com/",
"headers": {
"Referer": "https://security-site.com/"
},
"secure": false,
"changeOrigin": true,
"logLevel": "info"
}
}