Provides an authenticated proxy to Office 365 + SharePoint Online or an on-prem SharePoint installation. Use as a part of development with SpFx Workbench or a custom toolchain.
- Install sp-workbench-api-proxy dependency
npm i --save-dev sp-workbench-api-proxy
- For development as a part of SPFx Workbench:
const gulp = require('gulp');
const build = require('@microsoft/sp-build-web');
const spApiProxy = require('sp-workbench-api-proxy')
build.initialize(gulp);
gulp.task('serve2', ['serve'], function(){
spApiProxy(require('./config/sp_deploy_settings.json'))
})
- Create a new file ./config/sp_deploy_settings.json (from project root)
{
"siteUrl": "https://{tenant}.sharepoint.com/sites/{site}/",
"projectName": "project",
"credentials": {
"userName": "{user}@{tenant}.onmicrosoft.com",
"passWord": "**************"
}
}
- Add the following line to .gitignore
/config/sp_deploy_settings.json
- Run workbench with proxy
gulp serve2