Search code examples
javascriptangularjsangular-component-router

Angular 1 component router: Cannot read property 'startsWith' of undefined


I'm using Angular 1 component router and it works weired. When I run website locally it works fine, but if I access it from another PC I receive js error

Cannot read property 'startsWith' of undefined

I tried to access website from 4-5 PCs and different browsers IE, Chrome and Safari, it either works or displays js error,

Please advice


Solution

  • The issue was in base href url.

    I setup location provider to use HTML5 mode and added base href to the page like following:

    <base href="/Application/">
    

    When I access the http://company-domain.com/application I see JS error, but when I access the http://company-domain.com/Application it works as expected. That is why it was working not stable for me, I didn't pay much attention to the base url.

    So, the issue was not in component router, but how location provider parses the base href.

    Stupid issue, but the way that base href is case sensitive and can't be configured to be case insensitive is pain.

    Keep an eye on that.