yuan xu
我是个programmer
关注

请教搭建项目时候遇到的问题

世剑大神, 你好,


我正在学习你的小度鱼项目,试着自己把你的项目在自己的server架起来,现在遇到这个bug

Refused to apply style from 'http://159.89.133.159:4000/root/xiaoduyu-web/dist/client/styles.d932a8d9af4237c2ee49.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

请问该怎么解决

3条评论

我尝试了用nginx 设置reverse proxy的方式来解决,但还是没有效果。本地跑起来api和网站都没有问题

回复

这是我github目前的配置(项目已经被打包好了),第一个是api的https://github.com/xuyuan1994/api-xiaoduyu-final, 第二个是网站的https://github.com/xuyuan1994/xiaoduyu-web。 这是我的目前的etc/nginx/sites-available/default的配置:

server{


        listen 80;

        root /root/xiaoduyu-web;

        server_name www.ddfantasies.com ddfantasies.com;


        location / {

                proxy_pass http://localhost:4000;

                proxy_set_header Host $host;

                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

                proxy_set_header X-Forwarded-Proto $scheme;

                proxy_http_version 1.1;

                proxy_set_header Upgrade $http_upgrade;

                proxy_set_header Connection "upgrade";

                proxy_cache_bypass $http_upgrade;

        }

        location /dist/client/{


}


}

可以请大神看看我哪里出错,该怎么debug吗


回复

你好,感觉应该是publicPath这里的问题?

https://github.com/54sword/xiaoduyu.com/blob/master/config/index.default.js#L36


静态资源地址修改成这样可以正常访问,说明publicPath这里填写的有问题

http://159.89.133.159:4000/styles.d932a8d9af4237c2ee49.js


尝试修改成 //159.89.133.159:4000,然后重新打开试一试。

回复