Often, web applications aren’t deployed to the root path of a web server. Also, often, developers (me included) develop applications with the intent of deploying to the root path.
Overcoming this problem with an Angular app, while also making a local build against IIS Express and a production deploy work, is relatively straight forward.
With Angular, setting a root, or base, path is simple. We add a “base” element right after the head element of our pages. Angular will utilize this base on ALL requests.
<base href="/myApp/" />
The only thing we have to be aware of is that all of our paths in $resource, $http, templates refs, or whatever have to be relative paths. IE – there should be no leading slashes. With only that tiny bit of information, Angular will append “/myApp/” to every request.
In Visual Studio’s IIS Express settings, we need to be explicit about the default path as well:
With that bit of configuration in place, I can browse to my app at the sub-folder path and everything works as expected.