我正在使用react-router,React 0.14和nginx来渲染一个通用的JS应用程序.因为我正在转换现有的应用程序,我需要将新的'react'代码放在url前缀后面,比如说/foo
但是,我理想地喜欢nginx配置来处理在proxy_pass
本地端口上运行的react服务器(例如8080).
nginx conf
location /foo/ { proxy_pass http://localhost:8080/; proxy_set_header Host $host; }
反应路由器 routes.jsx
import HomePage from 'components/pages/HomePage'; import AboutPage from 'components/pages/AboutPage'; import NotFoundPage from 'components/pages/NotFoundPage'; export default ();
服务器上没什么特别的.服务器端呈现似乎工作正常,但当它到达客户端时,由于路径不匹配,它在控制台中显示以下警告:
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server: (client)我认为这是有道理的,因为URL实际上
http://localhost:80801/foo
不是http://localhost:8081/
客户端期望的反应路由器.除了将
/foo
前缀放在顶级路线之外,还有其他方法吗?我不想这样做的原因是我不想在/foo
任何地方都有前缀(例如在组件中).
MTIA!
1> Kyeotic-Stop..:您可以
baseURL
在设置历史记录对象时进行配置.import { createHistory, useBasename } from 'history' const history = useBasename(createHistory)({ basename: '/foo' })推荐阅读
如何解决《如何检查是否提供了液体模板的所有值?》经验,为你挑选了0个好方法。 ... [详细] 如何解决《Symfony2/Memcached集成》经验,为你挑选了1个好方法。 ... [详细] 如何解决《调试时会打开.class文件而不是.java》经验,为你挑选了2个好方法。 ... [详细] 如何解决《button_to使用GET方法》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何从ipodlibrary获取歌曲并使用AVPlayer播放》经验,为你挑选了1个好方法。 ... [详细] 如何解决《Java-为PC/Mac创建独立GUI应用程序的任何方法?》经验,为你挑选了0个好方法。 ... [详细] 如何解决《是否有任何工具可以在iOS应用运行时生成对象图?》经验,为你挑选了0个好方法。 ... [详细] 如何解决《IOS重复接口定义》经验,为你挑选了1个好方法。 ... [详细] 如何解决《防止包装菜单项》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何在android中保存图像和表面视图?》经验,为你挑选了0个好方法。 ... [详细] 如何解决《Symfony/Doctrine中的SQL注入》经验,为你挑选了2个好方法。 ... [详细] 如何解决《DataGridView:使用数组或List<t>添加新行》经验,为你挑选了1个好方法。 ... [详细] 如何解决《Chef中的动态角色属性》经验,为你挑选了1个好方法。 ... [详细] 如何解决《C#使用两个不同的相等比较器》经验,为你挑选了1个好方法。 ... [详细] 如何解决《DELPHI/ACCESSSELECTSQLERROR》经验,为你挑选了1个好方法。 ... [详细] 如何解决《在jqueryajax帖子上不断收到400(BadRequest)到MVC控制器》经验,为你挑选了1个好方法。 ... [详细] 如何解决《org.codehaus.jackson.map.JsonMappingException:无限递归(StackOverflowError)》经验,为你挑选了1个好方法。 ... [详细] 如何解决《PrimeFacescommandButton在confirmDialog中没有调用backingbean》经验,为你挑选了1个好方法。 ... [详细] 如何解决《使用客户端证书进行SSL重新协商会导致服务器缓冲区溢出》经验,为你挑选了1个好方法。 ... [详细] 如何解决《如何关闭类的jquery对话框?》经验,为你挑选了1个好方法。 ... [详细]吐了个 "CAO" !Tags | 热门标签RankList | 热门文章
- 1等待任务并静默停止取消或失败
- 2TensorFlow,如何通过CNN查看"blob"内部的响应
- 3你能看到客户端的PHP脚本吗?
- 4html2pdf在每个页面的页脚中添加内容
- 5JSR 363添加新单位
- 6printf没有打印过去'.' 在字符串中
- 7如何分配TextFile变量?
- 8erlang:now()在v18中已弃用,最佳转换是什么
- 9authorized_keys和id_rsa.pub之间的区别
- 10android"使用$代替." 生产无法解决符号
- 11我们可以从DOM中删除一个元素吗?
- 12将&str转换为OsStr的正确方法是什么?
- 13使用M2Eclipse插件在交互模式下使用versions-maven-plugin设置版本?
- 14有没有PHP DocBlock我可以用来表示实例化后添加的魔术方法属性?
- 15微服务:如何建模相关的域对象?
- 16无法加载类型Symfony2
- 17java中双精度的选择排序
- 18为什么main不等到异步方法完成?
- 19我应该在一个块中使用哪个NSAssertion?
- 20Obj-c表达式错误 - 二进制表达式的操作数无效('CGFloat'(又名'double'))
DevBox开发工具箱 | 专业的在线开发工具网站 京公网安备 11010802040832号 | 京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有