koltyakov / sp-rest-proxy

🌐 SharePoint API Proxy for local development
MIT License
172 stars 43 forks source link

Can this react app be deployed as a web app on to a windows server so that users can access the app outside of the server ? #139

Open noah09dvlpr opened 2 years ago

noah09dvlpr commented 2 years ago

I am trying to build a react app outside of SharePoint but the app should fetch the SharePoint Search API. I could not find a way to establish the connection from react app to SharePoint except yours. I have two questions:

  1. Can I deploy your cloned app as a web app onto IIS so that it can be used by other users ?
  2. How can I enable this app that it can take user ID and PWD everytime the app is tried to access by users ?
koltyakov commented 2 years ago

Hi @noah09dvlpr,

  1. No, sp-rest-proxy is a toolchain for development time. One should use anonymously exposed APIs for nothing but a local dev boosting. You need to deploy your React App to SharePoint page.

  2. It's not possible and never should be done this way. A React App should be hosted either at SharePoint page with SharePoint client & auth contexts or the app should auth SharePoint via OAuth2/OIDC from is a tenant allows. Yet another alternative is Provider Hosted apps, but I personally can't recommend this approach as too complex and legacy one.

noah09dvlpr commented 2 years ago

Thank you so much for quick response. This is a development project we are working on so we feel that it is okay to move forward with your app. Can you please confirm me that if I deploy this app onto a IIS server, will it work as a web app which can do the same job as it does on local machine ?

koltyakov commented 2 years ago

Generally, Node.js servers are not deployed to IIS. IIS doesn't support Node.js OOTB, there are some experimental extensions but IIS is not the way running Node anyways. You can proxy with ARR in IIS or use another reverse proxy which is more natural for modern era.

For dev scenarios, you always run sp-rest-proxy only locally next to Local Dev Server or inside it https://github.com/koltyakov/sp-rest-proxy#webpack-dev-server

noah09dvlpr commented 2 years ago

I face the below error when I try to build the app. Tried every other solution available online but does not help. Thanks in advance. image

And the dist folder fails to have the html and js files required for the app to host on IIS. IIS is all configured to run the app but the files are not generated. image

koltyakov commented 2 years ago

I face the below error when I try to build the app.

Not an error, warning. One of the linter plugins has a restriction for TypeScript version.

You don't need building sp-rest-proxy from sources. It's an installable library.

And the dist folder fails to have the html and js

And it should not contain any html.

required for the app to host on IIS

A Node.js can't be hosted with IIS. It's server side JavaScript, IIS can't run Node.js, it can proxy to a server with ARR. There are such experiments like iisnode but they don't have a lot sense.

I'd recommend not to waste time with IIS. Industry standards are a normal reverse proxy, e.g. Nginx/HAProxy/Traefik/etc., to and Node.js process(es).

And once again, hosting sp-rest-proxy for all devs and meaningless and not a good idea. It should be just integrated to your local dev server pipeline and act as a dev dependency within SPA. Please check this article describing the process in details.