Changing Access-Control-Allow-Origin permission for jquery load () to work

SITUATION:

  • An internal website launched from a web server.
  • SharePoint starts another internal web server.
  • All internal and all in one internal domain of company.com (different subdomains, because they are accessed through SharePoint.company.com and internalWeb.company.com )

Problem:

  • XMLHttpRequest cannot load http://SharePoint.company.com. The origin of http://internalWeb.company.com not permitted by Access-Control-Allow-Origin.

WHAT I WANT:

  • Use the ajax function and jQuery load () from my websites, web server to call the URLs on the SharePoint server.

Note:

  • It seems like you need to set the SharePoint server to allow cross-lookup requests by just setting Access-Control-Allow-Origin, it is ALL INTERNAL and I can change the settings for web.configs or IIS as I like.
  • Is it possible? If so, where do I install it. I read a lot about this and it seems that I cannot get a clear answer.

CODE: ( internalWeb.company.com running on my webpage)

 $("#details").load("SharePoint.company.com/someDetails.html"); 

Thanks!

+6
source share
1 answer

A quick fix might be to set up a custom header in your SharePoint web.config website:

http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders

 <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> 

Or try for this domain

 <customHeaders> <add name="Access-Control-Allow-Origin" value="http://internalWeb.company.com" /> </customHeaders> 
+9
source

Source: https://habr.com/ru/post/951397/


All Articles