A while ago I wrote about SharePoint Apps in MVC and how to get them working.
With ShareCoffee v0.1.2 - which is already available on nuget and bower - you can now ensure that SPHostUrl is appended to all links in your Apps without making changes to
spcontext.js which is provided by Microsoft.
You can now remove the OOB bundle config and references to
spcontext.js from your Apps and use a single function in order to extend all links and forms by simply calling
Compared to Microsoft’s implementation, mine has been done without referencing jQuery, which means you can also get rid of jQuery if you want to.
The logic itself is the same. Depending on the current authority and protocol type SPHostUrl will be appended to the href attribute of links AND to all action attributes of form tags.
Everyone who’s bought my ShareCoffee eBook at leanpub will receive an free book update in the upcoming days. So I’ll describe it there again in order to ensure completeness.