Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
cf-bindings-proxy
Advanced tools
Experimental proxy for interfacing with bindings in projects targeting Cloudflare Pages
Experimental proxy for interfacing with bindings
in projects targeting Cloudflare Pages.
This library was written to accompany @cloudflare/next-on-pages
, so that you can use bindings when developing Next.js apps locally through next dev
.
It is intended to be used for frameworks that do not support Cloudflare bindings in a fast HMR environment.
Add the library to your project.
npm add cf-bindings-proxy
In a separate terminal window, run the following command to start the proxy, passing through your bindings are arguments.
npx cf-bindings-proxy --kv=MY_KV
In your project's code, import the binding
function from cf-bindings-proxy
and use it to interact with your bindings.
import { binding } from 'cf-bindings-proxy';
const value = await binding<KVNamespace>('MY_KV').get('key');
It is also possible to specify a custom fallback for use in production instead of process.env
.
import { binding } from 'cf-bindings-proxy';
const value = await binding<KVNamespace>('MY_KV', { fallback: platform.env }).get('key');
Starting the proxy spawns an instance of Wrangler using a template, passing through any commands and bindings that are supplied to the CLI. It uses port 8799
.
In development mode, when interacting with a binding through the binding('BINDING_NAME')
function, it sends HTTP requests to the proxy. These HTTP requests contain destructured function calls, which are then reconstructed and executed inside the proxy. The result is then returned to the client.
When building for production, binding('BINDING_NAME')
simply calls process.env.BINDING_NAME
to retrieve the binding instead. If you wish to use a custom fallback like platform.env
instead of process.env
, you can pass a custom fallback to the binding call with binding('BINDING_NAME', { fallback: platform.env })
.
Calls to binding('BINDING_NAME')
will try to use the proxy when either of the following two conditions are met:
ENABLE_BINDINGS_PROXY
environment variable is set to true
.
ORDISABLE_BINDINGS_PROXY
environment variable is not set and NODE_ENV
is set to development
.Note: Functionality and bindings not listed below may still work but have not been tested.
0.7.1
FAQs
Experimental proxy for interfacing with bindings in projects targeting Cloudflare Pages
The npm package cf-bindings-proxy receives a total of 106 weekly downloads. As such, cf-bindings-proxy popularity was classified as not popular.
We found that cf-bindings-proxy 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools oft miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.