Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering images on Azure Web App from SharePoint Document Library #1876

Closed
1 of 4 tasks
freyes17 opened this issue Sep 10, 2021 · 5 comments
Closed
1 of 4 tasks

Rendering images on Azure Web App from SharePoint Document Library #1876

freyes17 opened this issue Sep 10, 2021 · 5 comments

Comments

@freyes17
Copy link

Category

  • Enhancement
  • Bug
  • Question
  • Documentation gap/issue

Version

Please specify what version of the library you are using: [ 2.0.0 ]

Please specify what version(s) of SharePoint you are targeting: [ SharePoint Online ]

If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.

Question

I am creating an Azure Web App that pulls data from SharePoint Online. Without issues, I am able to request the images from the document library but can't render them into the web page until I open a new tab directly visiting the SharePoint site. After I visit the site, the images I pulled now properly display on the Azure Web App.

When I don't visit the SharePoint site first.
image

After I visit the SharePoint site on a different tab.
image

I am using @azure/msal-browser v2.14.1 to authenticate if that information is useful.

Any possible work around? or recommendations?

Thank you in advance for any suggestions.

@koltyakov
Copy link
Member

Hi @freyes17, thanks for posting an issue!

This is non-library one, actually.

But the behaviour - when you have not been visiting SP site these images are unavailable with 401 or not cached.
After you've visited a site the images available.

Please check what you see in the browser network console. The images requests fails with 401, not authenticated.

Anyways, it's architecturally incorrect to link images cross-resources not holding authentication.
Using MSAL won't help while each and every resource request contains Bearer token.

It's better think out moving images to a resource which is accessible from within your app or publicly through CDN for example.

@freyes17
Copy link
Author

Thank you for your help. I appreciate the feedback.

Just to clarify I don't seem to be getting a 401 error. I do get a 302 warning with the following in the request.

console tab

image
network tab

image

When visiting the site I never visit the actual images in the Document Binder. I just visit the site https://site.sharepoint.com/sites/examplesite and it works after triggering the visit. So I don't think it is caching the actual image.

Not sure if this changes anything. Either way, thank you.

@koltyakov
Copy link
Member

302 is a redirect, so while not having a cookie a resource redirects to the login page, but as it’s a src in an img tag - no actual redirect. The recommendation is still publishing assets to the app infra, server-side proxying, or configuring CDN (if anonymous exposure is an option). For the CDN please check this doc.

@patrick-rodgers
Copy link
Member

Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!

@github-actions
Copy link

github-actions bot commented Nov 7, 2021

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants