New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

local-cors-proxy

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

local-cors-proxy - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

26

lib/index.js
var express = require('express');
var request = require('request');
var cors = require('cors');
var chalk = require('chalk');
var proxy = express();

@@ -9,13 +10,30 @@

proxy.options('*', cors());
// remove trailing slash
var cleanProxyUrl = proxyUrl.replace(/\/$/, '');
// remove all forward slashes
var cleanProxyPartial = proxyPartial.replace(/\//g, '');
proxy.use('/' + cleanProxyPartial, function(req, res) {
// remove trailing slash
var cleanProxyUrl = proxyUrl.replace(/\/$/, '');
req.pipe(request(proxyUrl + req.url)).pipe(res);
try {
console.log(chalk.green('Request Proxied -> ' + req.url));
} catch (e) {}
req.pipe(request(cleanProxyUrl + req.url)).pipe(res);
});
proxy.listen(port);
console.log('Proxy Active');
// Welcome Message
console.log(chalk.bgGreen.black.bold.underline('\n Proxy Active \n'));
console.log(chalk.blue('Proxy Url: ' + chalk.green(cleanProxyUrl)));
console.log(chalk.blue('Proxy Partial: ' + chalk.green(cleanProxyPartial)));
console.log(chalk.blue('PORT: ' + chalk.green(port) + '\n'));
console.log(
chalk.cyan(
'To start using the proxy simply replace the proxied part of your url with: ' +
chalk.bold('http://localhost:' + port + '/' + cleanProxyPartial + '\n')
)
);
};
exports.startProxy = startProxy;

3

package.json
{
"name": "local-cors-proxy",
"version": "1.0.1",
"version": "1.0.2",
"main": "./lib/index.js",

@@ -23,2 +23,3 @@ "scripts": {

"dependencies": {
"chalk": "^2.3.2",
"command-line-args": "^5.0.2",

@@ -25,0 +26,0 @@ "cors": "^2.8.4",

@@ -39,8 +39,16 @@ # Local CORS Proxy

Alternatively you can install the package locally and add a script to your project:
```json
"scripts": {
"proxy": "lcp --proxyUrl https://www.yourdomain.ie"
}
```
## Options
| Option | Example | Default |
| -------------- | -------------------- | ------: |
| --proxyUrl | http://www.google.ie | |
| --proxyPartial | foo | proxy |
| --port | 8010 | 8010 |
| Option | Example | Default |
| -------------- | --------------------- | ------: |
| --proxyUrl | https://www.google.ie | |
| --proxyPartial | foo | proxy |
| --port | 8010 | 8010 |

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc