question

susmitha-6036 avatar image
0 Votes"
susmitha-6036 asked susmitha-6036 commented

Unable to get info from cross domain into Sharepoint content editor webpart

Hello,
We have been trying to display content from different domain using JSON link. We have 2 files (html and JS) which extracts data from JSON and displays over content editor webpart in our Sharepoint 2013. When we use VS code live server it works and content gets displayed.

We have added these 2 files into Site assets library and added link in a content editor which gives error as attached screenshot.
108438-ms-issue-for-ov.png


Can Someone help me with this?

Regards,
Susmitha.


office-sharepoint-server-customization
ms-issue-for-ov.png (20.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

sadomovalex avatar image
0 Votes"
sadomovalex answered

like error description says json file from external site which you try to get is blocked because this external site has The Same Origin Policy. Which means it will allow client-side requests only if they come from the same domain. If you have possibility - you may contact owners of this external site and ask to add your domain to Access-Control-Allow-Origin response header. If not - you may implement server-side proxy (this is possible since you work with SP2013 on-prem) - e.g. custom ashx handler in Layouts folder. This handler will get json file from external site via internal http request and will return it to the caller. In your jQuery code you will then call this ashx handler instead of external site. It will allow to avoid problems with CORS.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered susmitha-6036 commented

Hi @susmithakatreddy-6036,

This is security Feature of browsers. We cannot make a Request to another Domain using Javascript.

As @sadomovalex said, If it's possible, you need to add a "Access-Control-Allow-Origin" Header to the server.


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@susmithakatreddy-6036,
How are things going? Is there any update on your issue?
I am willing to hear from you.

0 Votes 0 ·

Hi,

The issue still persists even after adding "Access-Control-Allow-Origin" Header to the server. We tried contacting Vendor with the error msg and asked to check it from their end.

Regards,
Susmitha

0 Votes 0 ·