如果
localhost:3000/search直接在浏览器导航栏中输入,浏览器将向服务器发出“
/搜索”请求,该请求可以在控制台中看到(请确保选中“保留日志”按钮)。
Navigated to http://localhost:3000/search
如果运行全静态服务器,则会生成错误,因为服务器上不存在搜索页面。例如,使用express,您可以捕获这些请求并返回index.html文件。angular2引导程序启动,并且@RouteConfig中描述的/
search路由已激活。
// example of express()let app = express();app.use(express.static(static_dir));// Additional web services goes here...// 404 catch app.all('*', (req: any, res: any) => { console.log(`[TRACE] Server 404 request: ${req.originalUrl}`); res.status(200).sendFile(index_file);});


