Search code examples
angularjstypescriptroute-provider

Why aren't I getting a 404 with an unhandled state?


I am using $stateProvider to set-up my states like so:

constructor($stateProvider, $urlRouterProvider, $locationProvider) {
    $stateProvider.
        state("something", {
            url: "/index.html"
        })
       // many more
}

I am not using $urlRouterProvider.otherwise('default-something');, so when I type /invalidstate, I was expecting a 404. Instead, I'm getting a 200 response.

What I'm trying to do is set up a 404 interceptor, but in order for me to intercept, I have to get a 404. I can't fathom for the life of me why a state that's not handled would result in a 200.


Solution

  • You are getting a 200 response because so far as the server is concerned, that is a valid route.