Skip to content

Commit 06e591b

Browse files
author
yunkui.zhou
committedMay 10, 2018
req.originalUrl替换为req.baseUrl和req.path
1 parent 79541cc commit 06e591b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed
 

Diff for: ‎bin/www

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ if (process.env.NODE_ENV === 'local') {
1717
const app = require('../server/index').default
1818
const http = require('http')
1919
const server = http.createServer(app)
20-
server.listen('8888', () => {
21-
console.log('启动成功,监听端口:8888')
20+
server.listen('8888', '127.0.0.1', () => {
21+
console.log(`启动成功,监听端口:${server.address().port}`)
2222
})

Diff for: ‎server/routes/pages.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ router.get('/', (req, res) => {
2222
})
2323

2424
router.get('/integration(/:page)?', extractMapping, (req, res, next) => {
25+
const location = `${req.baseUrl}${req.path}`
2526
const content = renderToString(<Provider store={store(reducers)}>
2627
<StaticRouter
27-
location={req.originalUrl}
28+
location={location}
2829
context={{}}
2930
basename="/p/integration"
3031
>
@@ -40,8 +41,9 @@ router.get('/integration(/:page)?', extractMapping, (req, res, next) => {
4041

4142
router.get('/components(/:page)?', extractMapping, (req, res, next) => {
4243
//可以根据路径,针对某一个页面进行服务端渲染
44+
const location = `${req.baseUrl}${req.path}`
4345
const content = renderToString(<StaticRouter
44-
location={req.originalUrl}
46+
location={location}
4547
context={{}}
4648
basename="/p/components">
4749
<Component/>

0 commit comments

Comments
 (0)
Please sign in to comment.