Files
meanTorrent/modules/core/server/views/404.server.view.html
Mikael Korpela ba1a4475e9 #501 Handle 404 errors at Express backend at at Angular frontend
- `/{api|modules|lib}/*` returns error page when path doesn’t exist
(from Express).
- `/*` always returns index (from Express), but if `$state` doesn’t
exist, Angular redirects to `/not-found` (no 404 status in that case
though!)
- If `Accept: application/json` header is present without `Accept:
text/html`, return error as json. Hence looking at non existing /api/*
paths with browser would show html error, but querying them with script
would return json.
- Slightly prettier 404 error

Test:
```bash
curl http://localhost:3000/api/notfound -4 -H "Accept: application/json"
```
=> json error.

```bash
curl http://localhost:3000/api/notfound -4 -H "Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0
.8"
```
=> html error (imitates Chrome’s Accept header).

Starting point was @dotch’s PL: https://github.com/meanjs/mean/pull/503

And `req.accepts()` idea came from http://stackoverflow.com/a/9802006
2015-05-18 17:38:30 +03:00

11 lines
299 B
HTML

{% extends 'layout.server.view.html' %}
{% block content %}
<h1>Page Not Found</h1>
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
{{url}} is not a valid path.
</div>
{% endblock %}