Handling 404 Error in Ember with location type set as "hash"


#1

I have created a route called “page-not-found” in my ember application to catch all error routes. It is working fine when I type something erroneous in the URL like

http://localhost:4200/#/name-other-than-available-routes

Note the “hash” in the URL. I have specified my locationType as “hash”. Now I want to redirect to the “page-not-found” route even if the URL doesn’t contain hash in it. Currently, it is throwing me error "Cannot Get name-other-than-route" on the web page when I use like this.

http://localhost:4200/name-other-than-route

Is there any way to achieve this? Is this possible? Kindly assist me.


#2

You’re using the development server. The answer is that it doesn’t matter, because you won’t be using the development server when you deploy your app.

When you deploy your app, you’ll have to configure the server you use to handle those cases correctly


#3

Thanks @alexspeller. Even in deployment server I am facing this issue.

When you deploy your app, you’ll have to configure the server you use to handle those cases correctly

How to configure the server to handle those cases? Can you clarify me?


#4

You’ll have to look at the manual for your web server. ember serve is for development only, not for deployment. So have a look at the instructions for whatever server you are using in deployment.