Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const config = require('../config/project.config')
const server = require('../server/main')
const debug = require('debug')('app:bin:server')
const corsProxy = require('cors-anywhere')
if (config.env === 'development') {
corsProxy.createServer({
// originWhitelist: [], // Allow all origins
// requireHeader: [],
// setHeaders: { },
// removeHeaders: []
}).listen(config.cors_proxy_port, config.server_host, () => {
debug(`\n\n ⚠️ CORS proxy running on ${config.server_host}:${config.cors_proxy_port}`)
})
}
server.listen(config.server_port, () => {
debug(`\n\n 💻 Server is now running at ${config.server_host}:${config.server_port}.`)
})
// JavaScript CORS Proxy
// Save this in a file like cors.js and run with `node cors [port]`
// It will listen for your requests on the port you pass in command line or port 8080 by default
let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 4080 // default
require ('cors-anywhere').createServer ().listen (port, 'localhost')
let port = (process.argv.length > 2) ? parseInt (process.argv[2]) : 8080; // default
require ('cors-anywhere').createServer ().listen (port, 'localhost')
gulp.task('connect', function() {
var httpProxyOptions = {};
if(config.proxyAuth && config.proxyAuth.length > 0){
httpProxyOptions.auth = config.proxyAuth;
}
corsAnywhere.createServer({
originWhitelist: [],
httpProxyOptions : httpProxyOptions
}).listen(config.proxy_port, 'localhost', function() {
console.log('Running CORS Anywhere on ' + 'localhost' + ':' + config.proxy_port);
});
connect.server({
root: config.build_dir,
livereload: true,
port: config.connect_port
});
});
gulp.task('proxy', function() {
var host = '0.0.0.0';
var port = 1337;
cors_proxy.createServer().listen(port, host, function() {
console.log('Running CORS Proxy on ' + host + ':' + port);
});
})
httpServer.listen(COOPR_UI_PORT, null, null, function () {
console.info(httpLabel + ' listening on port %s', COOPR_UI_PORT);
});
}
if (COOPR_SSL) {
httpsServer.listen(COOPR_UI_SSL_PORT, null, null, function () {
console.info(httpLabel + ' listening on port %s', COOPR_UI_SSL_PORT);
sslStarted = true;
});
}
/**
* CORS proxy
*/
corsAnywhere.createServer({
requireHeader: ['x-requested-with'],
removeHeaders: ['cookie', 'cookie2']
})
.on('request', function (req, res) {
corsLogger(req, res, function noop() {
});
})
.listen(COOPR_CORS_PORT, '0.0.0.0', function () {
console.info(corsLabel + ' listening on port %s', COOPR_CORS_PORT);
});
cert: fs.readFileSync(COOPR_UI_CERT_FILE, 'utf-8')
}, app);
}
else {
server = http.createServer(app);
}
server.listen(COOPR_UI_PORT, null, null, function () {
console.info(httpLabel + ' listening on port %s', COOPR_UI_PORT);
});
/**
* CORS proxy
*/
corsAnywhere.createServer({
requireHeader: ['x-requested-with'],
removeHeaders: ['cookie', 'cookie2']
})
.on('request', function (req, res) {
corsLogger(req, res, function noop() {});
})
.listen(COOPR_CORS_PORT, '0.0.0.0', function () {
console.info(corsLabel + ' listening on port %s', COOPR_CORS_PORT);
});
COOPR_CORS_PORT: COOPR_CORS_PORT,
authorization: req.headers.authorization
}));
}
]
})
.listen(COOPR_UI_PORT, '0.0.0.0', function () {
console.log(httpLabel+' listening on port %s', COOPR_UI_PORT);
});
/**
* CORS proxy
*/
require('cors-anywhere')
.createServer({
requireHeader: ['x-requested-with'],
removeHeaders: ['cookie', 'cookie2']
})
.on('request', function (req, res) {
corsLogger(req, res, function noop() {} );
})
.listen(COOPR_CORS_PORT, '0.0.0.0', function() {
console.log(corsLabel+' listening on port %s', COOPR_CORS_PORT);
});
res.header('Access-Control-Allow-Credentials', 'true');
next();
});
}
app.use('/sw.js', (req, res) =>
res.sendFile(path.resolve(__dirname, 'dist', 'sw.js'))
);
app.use('/static', Express.static(path.resolve(__dirname, 'dist')));
app.get('/*', (req, res) =>
res.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
);
app.listen(process.enve.SERVER_PORT, () =>
console.log('Listening on', process.enve.SERVER_PORT)
);
proxy
.createServer({
originWhitelist: [process.enve.WEB_URL],
requireHeader: ['origin', 'x-requested-with']
})
.listen(process.enve.PROXY_PORT, '127.0.0.1');
var cors_proxy = require('cors-anywhere');
var host = process.argv[4] || 'localhost';
var port = 1337;
cors_proxy.createServer().listen(port, host, function() {
console.log('Running CORS Proxy on ' + host + ':' + port);
});