Ant Design Pro is deployed to a small problem encountered aliyun oss

9794326-03801ec59bf01cd1


In the past we all buy server hosting, then the front page and back-end services on the same machine, the domain name resolution to this server, nginx through binding domain, and point to the directory where the front page, front page request interface, configure nginx proxy forwarding, such as matching the '/ xxxx', is forwarded to the back-office services.

       But we decided to make the front page (html, js, css, images and other static resources) deployed to (Ali cloud object storage service (Object Storage Service, referred to as OSS), then the background interface allows cross-domain requests.

These are set up, I'll Ant Design Pro project package upload to aliyun oss, everything is normal, but you can not refresh the page, refresh the page on a report this error, the error message: This XML file does not appear to have any style information associated with it. The document tree is shown below.

Figure

9794326-7253c6bbb5ae9194

       The problem with the front-end routing relationship, Ant Design Pro (> = 2.0) using UmiJS, umi is the default Browser History, if you use Hash History, you need to configure:

exportdefault{

history:'hash',

}

       If we use the default configuration (Browser History), in the past, we need to configure nginx in:

location / {

        # For use with browserHistory

        try_files $ on $ a / /index.html;

    }

       In aliyun oss, we can set up on the basis of -> to set the image back to the source, can achieve such results.

Set as follows:

figure 1

9794326-182cc147c6448e3f

figure 2

9794326-540424c1ef96fffb

           After setting takes effect immediately, and then refresh the page to normal.



9794326-03801ec59bf01cd1

Reproduced in: https: //www.jianshu.com/p/0bc309057ca6

Guess you like

Origin blog.csdn.net/weixin_34146986/article/details/91309804