当谷歌索引我的角度Web应用程序 . 它看不到页面,在控制台中我有这个错误:
SecurityError:无法在'History'上执行'replaceState':具有URL'https://MYDOMAIN/universe/ ' cannot be created in a document with origin ' https://webcache.googleusercontent.com ' and URL ' https://webcache.googleusercontent.com/search?q=cache:YlVK5uwbqWcJ:https://MYDOMAIN> / universe&cd = 2&hl = fr&ct = clnk&gl = fr'的历史状态对象 .
但我不明白这个错误 . 这是否意味着我必须允许webcache.googleusercontent的交叉来源?
我目前正在使用angular universal和nginx作为反向代理 .
1 回答
如果您希望自己的历史记录在从Google缓存访问您的身边时有效,则在调用
pushState
时需要使用相对URL . AFAIK,没有交叉原点设置会改变这一点 .https://developer.mozilla.org/en-US/docs/Web/API/History_API
您可以使用hashLocation策略而不是默认路径位置策略(https://angular.io/guide/router#appendix-locationstrategy-and-browser-url-styles) . 这应该可以解决问题