Ant-design-pro: How to deploy ant-design-pro under subfolder?

Created on 23 Nov 2017  ·  3Comments  ·  Source: ant-design/ant-design-pro

Hi, everyone. I want to deploy ant-design-pro under subfolder with using browserHistory instead of hashHistory. This subfolder is '/myapp'. In this way, this entry point would like this:

// entry point
http://localhost:8000/myapp/

//dashboard - analysis
http://localhost:8000/myapp/dashboard/analysis

I look around roadhog tutorial docs and I found out that I should config .roadhogrc by adding:

"publicPath": "/myapp/"

It works out when I visit http://localhost:8000/myapp/. When I jump to other route by clicking navbar, the url changes to http://localhost:8000/list/table-list, which I expected is http://localhost:8000/myapp/list/table-list. How should I figure it out?

Most helpful comment

当下的pro master模板如何使用publicPath呢?

All 3 comments

@afc163 Thanks, I reviewed rearc-router v4 docs. I found out that BrowserRouter with basename props could solve my problem.
I should change code in src/router.js from:
https://github.com/ant-design/ant-design-pro/blob/7532598937198bef0fce344b3521f9e3c5044755/src/router.js#L54-L61

to:

    <LocaleProvider locale={zhCN}>
      <BrowserRouter basename="myapp">
        <Switch>
          <Route path="/user" render={props => <UserLayout {...props} {...passProps} />} />
          <Route path="/" render={props => <BasicLayout {...props} {...passProps} />} />
        </Switch>
      </BrowserRouter>
    </LocaleProvider>

Solve it!

当下的pro master模板如何使用publicPath呢?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renyi818 picture renyi818  ·  3Comments

yadongxie150 picture yadongxie150  ·  3Comments

yjz1004 picture yjz1004  ·  3Comments

suifan picture suifan  ·  3Comments

lvzheng0404 picture lvzheng0404  ·  3Comments