Angular Universal 生成 404(和其他 HTTP 代码)标头 [英] Angular Universal generate 404 (and other HTTP codes) header
问题描述
我正在使用 Angular Universal 创建一个网站.它将具有服务器端呈现,以便搜索引擎对其进行索引.
I'm creating a website using Angular Universal. It will have server-side rendering in order to make it indexable by search engines.
我已经编码了我的 404 回退路由,它正确显示了它的组件,但它显示了一个 HTTP 200 标头代码.
I already coded my 404 fallback route, it displays its component correctly, but it displays it with a HTTP 200 header code.
如何强制使用特定的标头代码?我用谷歌搜索了一些查询,但我发现的一切似乎都是关于读取一个 HTTP 调用的状态代码,而没有关于如何将它写入到浏览器.
How can I force a specific header code ? I googled some queries, but everything I found seemed to be about reading an HTTP call's status code, and nothing on how to write it to the browser.
推荐答案
好的,我终于成功了.
我重新开始,使用 Angular Universal Starter (CLI) 和 Patrick Michalina 的脚本此处描述:https://github.com/DSpace/dspace-angular/issues/91#issuecomment-318547118
I started over, and used Angular Universal Starter (CLI), with Patrick Michalina's scripts described here : https://github.com/DSpace/dspace-angular/issues/91#issuecomment-318547118
这篇关于Angular Universal 生成 404(和其他 HTTP 代码)标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!