chendishen / react-live2d

在react项目里展示live2d看板娘:react-live2d
Other
78 stars 17 forks source link

打包部署后,发现资源请求路径拼错了? #4

Closed weijie-he closed 3 years ago

weijie-he commented 3 years ago

本地开发环境没有问题,但是打包部署后,发现资源请求路径拼错了,路径多了一个“/” image

chendishen commented 3 years ago

今天有另一位使用者也反馈了类似的问题,设置PathFull={'../Resources/'},PathFull可以设置绝对路径或者相对路径,正确指向到模型资源就可以了

weijie-he commented 3 years ago

好的,之前没有注意到还有这个参数。

weijie-he commented 3 years ago

好像改了还是不对,PathFull 设置的路径,只到Resources这一层,但出错的是下一层,Hiyori这层。 我觉得是不是下面这边代码写的有问题。 你modelPath中最后已经加了“/”了,但是传入到loadAssets方法中,拼接路径时又加了“/”。 image

image

chendishen commented 3 years ago

其实,请求资源的双斜杠不会导致你加载不出来,你报错是500

chendishen commented 3 years ago

我实例网站里是直接build发布上去的,资源指向是跟run dev一样,也不需要额外修改资源指向。那位使用者的遇到的需要PathFull重新指向目录,是因为他的目录结构不一样,所以需要重新指向资源。

weijie-he commented 3 years ago

因为我后端使用了spring security 。报错信息是这样的:

There was an unexpected error (type=Internal Server Error, status=500).
The request was rejected because the URL contained a potentially malicious String "//"

有双斜杠的话,请求会被拒绝,你可以参考一下这个链接: The request was rejected because the URL was not normalized

chendishen commented 3 years ago

@weijie-he 已经发布了新的版本,你可以尝试一下问题有没解决

weijie-he commented 3 years ago

解决了,非常感谢!