sp-rest-proxy
🌐 SharePoint REST API Proxy for local Front-end development tool-chains
Last updated
🌐 SharePoint REST API Proxy for local Front-end development tool-chains
Last updated
Allows performing API calls to local Express application with forwarding the queries to a remote SharePoint instance.
Original concept of the proxy was created to show how it could be easy to implements real world data communications for SharePoint Framework local serve mode during web parts debug without deployment to SharePoint tenant. Now the tool is used with multiple teams for modern front-end solutions rapid development.
SharePoint Online
SharePoint On-Prem (2019, 2016, 2013)
SharePoint On-Prem 2010 (limited support)
>= 10.19
REST API
CSOM requests
SOAP web services
Static resources
API Proxy server
Socket gateway server
Socket gateway client
Custom Express apps embed mode
Socket proxying allows to forward API from behind NAT (experimental).
1. Install NPM module in the project:
2. Create server.js with the following code:
Configuration parameters cheatsheet
3. Add npm task for serve into package.json:
Check if the path to server.js is correct.
4. Run npm run serve
.
5. Provide SharePoint configuration parameters.
6. Test local API proxy in action.
1. Clone/fork the project:
2. CMD to the project folder.
3. Install dependencies:
4. Build:
5. Run the server:
or serve in TypeScript directly
Prompts credentials for a SharePoint site.
6. Navigate to http://localhost:8080
(or whatever in settings)
7. Ajax REST calls as if you were in SharePoint site page context:
8. Tests.
In early days of sp-rest-proxy
, the library was written in ES6 and used module.exports
which was kept after migrating to TypeScript later on for the backward compatibility reasons.
In TypeScript, it's better to import the lib from sp-rest-proxy/dist/RestProxy
to get advantages of types:
The proxy provides wizard-like approach for building and managing config files for node-sp-auth
(Node.js to SharePoint unattended http authentication).
SharePoint Online:
User credentials (SAML/ADFS)
Add-In Only permissions
On-Demand authentication (using Electron popup)
SharePoint 2019, 2016, 2013:
User credentials (NTLM, NTLM v2)
ADFS user credentials
Form-based authentication (FBA)
Form-based authentication (Forefront TMG)
Add-In Only permissions
On-Demand authentication (using Electron popup)
SharePoint 2010:
User credentials (NTLM, NTMLv2)
Form-based authentication (FBA)
Form-based authentication (Forefront TMG)
For more information please check node-sp-auth credential options and wiki pages. Auth settings are stored inside ./config/private.json
.
sp-rest-proxy works with PnPjs (check out brief notice how to configure).
sp-rest-proxy includes helper method for configuring page context - loadPageContext
.
JSOM can be used in local development mode with sp-rest-proxy with some additional setup.
The local development workbench page should contain JSOM init scripts:
Check out the example.
Blog post article with setting up SPFx and Proxy
Client side applications development with local serve, but real data from SharePoint
SharePoint Framework in local workbench with real data
Client applications integration test automation scenarios