Basic Example
- mysite.mysharepoint.com has clientside code that wants to access a list on mysharepoint.com due to whatever reason.
- the Same-origin policy forbids this
Possible Workarounds
SSOM
While this is easily possible, I tend to avoid serverside code.
Con
- SSOM
Edit web.config
An simple web.config edit allows the communication.
Con
- all front-end servers have to be modified
- hardware changes can affect the outcome
App
For Apps SharePoint provides some ways to enable cross-domain calls. (SP.RequestExecutor
, SP.WebProxy
) so you could communicate with the app and the app communicates cross domain. Same for CSOM apps while you here can work without the policy.
Con
- need of an app
WebService
Editing your own web-service's web.config isn't as critical as editing the SharePoint one. The web-service itself could access the data via SSOM (needs to be hosted on a SP server) or CSOM (much more the 2013 way). If configured correct, the service returns JSONP which can be consumed.
Con
- need of an web-service
Conclusion
If you have any suggestions or know other ways to solve the problem (SP365 Custom Action?) feel free to add them to this collection.