Registry / api / wpcom-proxy-request

wpcom-proxy-request

JSON →
library7.0.7jsnpmunverified

Proxied cookie-authenticated REST API requests to WordPress.com. Current stable version is 7.0.7, released under the Automattic/wp-calypso monorepo with irregular release cadence. Uses a proxy to authenticate requests with browser cookies, ideal for WordPress.com OAuth-less integrations. Key differentiator from wpcom-xhr-request: simpler setup with automatic cookie handling, but only works in browser environments.

npm install wpcom-proxy-request
INSTALL
IMPORT
SIG · WPCOM-PROXY-REQUES
W
wpcom-proxy-request
apijavascriptv7.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import wpcomProxyRequest from 'wpcom-proxy-request'
const wpcomProxyRequest = require('wpcom-proxy-request')
Package is ESM-only since v7. Default export is the request function.
WPCOMProxyRequest
Type for the request function.

Demonstrates making a GET request to WordPress.com REST API with cookie-based authentication via proxy.

import wpcomProxyRequest from 'wpcom-proxy-request'; async function getUser() { try { const data = await wpcomProxyRequest({ path: '/me', apiVersion: '1.1', method: 'GET', }); console.log('User:', data); } catch (error) { console.error('Error:', error); } } getUser();
Debug
Known issues
breakingESM-only since v7
fix
Use import instead of require, or upgrade to Node.js 14+ for ESM support.
affects: >=7.0.0
gotchaOnly works in browser environments – not for Node.js server-side requests
fix
Use wpcom-xhr-request or wpcom-oauth for server-side.
affects: all
deprecatedapiVersion: '1.0' is deprecated
fix
Use apiVersion: '1.1' or newer.
affects: >=6.0
gotchaRequires user to be logged into WordPress.com and proxy to be set up on the same origin
fix
Ensure the request originates from a WordPress.com page or a site with the proxy enabled.
affects: all
Errors
Common errors & fixes
TypeError: wpcomProxyRequest is not a function
Using require with the default export instead of import
fix
Use import wpcomProxyRequest from 'wpcom-proxy-request'.
Error: No proxy detected
The request is not being made from a page that has the WordPress.com proxy
fix
Make sure the code runs on a WordPress.com page or a page that includes the proxy script.
Error: Request failed with status 403
User is not authenticated or cookie is invalid
fix
Ensure user is logged into WordPress.com and has appropriate permissions.
Upgrade
Version history
7.0.7latest on npm
Audit
Dependencies
debugoptionalDebug logging
progress-eventoptionalProgress events for uploads
Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
wpcom-proxy-request — npm install wpcom-proxy-request · libregistry