Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
remote
Advanced tools
Readme
Remote is a simple CLI tool that enables you to work in local files while consuming an API from a remote server. An easy reverse proxy in Node, if you will.
If you'd like, it can also start a simple local server for your files.
Simply specify
It aims to solve the dreaded cross domain request problem, so you can freely ajax like you have a local server-side.
npm install -g remote
After installing, create a remote.json
configuration file (check the example folder) and simply call remote
.
remote [options]
Options:
-h, --help output usage information
-V, --version output the version number
-d, --directory [path] Path to a local folder. If defined, will serve files at server address. [undefined]
-r, --remote [host:port] Address of the remote API [localhost:80]
-p, --proxy [host:port] Address of the reverse proxy server [localhost:9001]
-s, --server [host:port] Address of the static file server [localhost:9000]
-m, --mapping Whether to use the mapping rules [false]
-f, --file [remote.json] Specific configuration file [remote.json]
See the example configuration file at the example folder.
Read on for the possible options for your remote.json
file.
This is the simplest remote.json
, with some bounce rules defined:
{
"directory" : "./src/",
"remote" : {"host": "remote-api-host.com", "port": 80},
"bounces" : [
"public/.*",
"assets/.*"
]
}
In this case, any call to localhost:3000/public/(...)
or localhost:3000/assets/(...)
will be bounced to your local files under ./src/
.
Other URL's will be forwarded to remote-api-host.com
You may wish to send along some headers with your request. For example:
{
"directory" : "./src/",
"remote" : {"host": "remote-api-host.com", "port": 80},
"headers": {
"Host": "remote-api-host.com",
"X-Secret-Header" : "awesome"
},
"bounces" : [
"public/.*",
"assets/.*"
]
}
These will be added to every request made by remote
.
A mapping is like a bounce rule, only more specific. You define what you want served given a request URL. For example:
{
"directory" : "./src/",
"remote" : {"host": "remote-api-host.com", "port": 80},
"headers": {
"Host": "remote-api-host.com",
"X-Secret-Header" : "awesome"
},
"bounces" : [
"public/.*",
"assets/.*"
],
"mapping": true,
"mappings": {
".*/api/users/1/remove": {"result": "ok"},
".*/api/users/.*":"./test/mocks/users-mock.json",
".*/files/.*":"./test/files/",
".*/public/js/awesome.js":"./src/special/path/awesome-2.js"
}
}
As you can see, mappings can be:
When any of these URL's are requested, remote will serve the given resource.
Note that mappings take precedence over bounce rules!
You can disable all mappings setting mapping
to false.
If you like to keep things complicated, you may use the bounceToRemote: true
option in your configuration file.
This will invert the bounces
rules, so they will actually bounce to the remote API. All other requests will be forwarded to the local server.
Command line options take precedence over remote.json
options.
Also, any command line option may be specified in the json configuration file.
Have fun!
OS X has a arbitrarily low limit for the amount of files that a process can open of 256.
Use the ulimit
command to check your current limit.
For sites with large amounts of files, or in any situation when encountering EMFILE errors, simply issue:
ulimit -n 2048
Or any such large value, before turning on remote.
v 0.2.6:
v 0.2.5:
v 0.2.4:
v 0.2.3:
v 0.2.1:
v 0.2.0:
v 0.1.0:
FAQs
Work on client-side files with a remote API server transparently
The npm package remote receives a total of 10,574 weekly downloads. As such, remote popularity was classified as popular.
We found that remote demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.