Closed Shmata closed 5 years ago
Hi @Shmata,
All is right. The current user is the one authenticated, the one which credentials are used in proxy, from private.json or passed to proxy settings somehow else. This user is the current. How could you expect somebody else? :) The proxy exposes an anonymous pre-authenticated local server so other toolchains like Webpack dev server, etc. just send requests as if they were already hosted on SharePoint page context and also solves CORS issues.
If you need to start dev server and test under a different user, you got to update private.json or switch between different private.json's with different creds before starting dev toolchain server.
I'm wondering, you probably miss the idea of the sp-rest-proxy. It's for dev time only. A developer starts the app server with API through the proxy, locally, and when applying the changes to the code receives instant build and hot page reload. As everyone got used with SPA dev toolchains. When the app is completed it is published to SharePoint assets and hosted from SharePoint.
sp-rest-proxy should be used only during development time. It's not something for exposing SharePoint via different URL or to another network. Such a scenario should be solved using a reverse proxy (e.g. IIS ARR, WAP, etc.).
Also, suggesting you try exposing the API to the app outside SharePoint in general, like a mobile app or any static site, PWA. This is also doesn't suppose to work this way. The app should take care of its authentication and logical permissions layer and send requests serverside. In such a scenario there will be no current user at all.
Hi @koltyakov
My fault was that in pnp setup section I didn't correct
baseUrl: "http://localPath:port"
to new "baseUrl" according to destination server, before "npm run build" Thanks for your attention and complete description.
Dear , I'm using pnpjs and sp-rest-proxy in my app , my sharepoint version is 2013 on-permisses . I have problem with get current user . I have to recognize current user in my app but I only got the user that is exist in "private.json" (I already enter to configure sp-rest-proxy) . How can i get another user ?